gpt4 book ai didi

c++ - 我在使用 Microsoft Visual C++ 进行 C++ 作业时需要帮助

转载 作者:太空狗 更新时间:2023-10-29 21:30:35 27 4
gpt4 key购买 nike

好的,所以我不想让你帮我做作业,但我对这个期末作业有点迷茫,需要我能得到的所有帮助。学习编程已经够难的了,但是在线学习对我来说几乎是不可能的……现在,为了进入程序,我将粘贴我目前所掌握的内容。这主要包括//comments 和我到目前为止所写的内容。如果你能帮我弄清楚所有的错误在哪里以及如何完成作业,我将不胜感激。就像我说的,我不想让你为我做作业(这是我的期末作业),但欢迎任何建设性的批评。这是我这门课的最后作业,明天(亚利桑那州时间,星期日午夜前)到期。

这是作业:

检查以下情况:

  • 贵公司 Datamax, Inc. 正在对其薪资系统进行自动化。您的经理要求您创建一个程序来计算所有员工的加类费。您的计划必须考虑员工的薪水、总工作时间以及每周工作时间超过 40 小时,然后提供有用且易于公司管理层理解的输出。

  • 利用以下背景信息和附录 D 中的代码大纲(包含在代码部分中)编译您的程序。

  • 将您的项目作为附件提交,包括代码和输出。

公司背景:

  • 三名员工:马克、约翰和玛丽
  • 需要提示最终用户输入三项特定内容:姓名、工作时间和小时工资。
  • 如果每周投入的时间超过 40 小时,则计算加类费。
  • 提供六个测试计划来验证程序中的逻辑。
  • 计划 1 必须显示带加类费的员工 #1 的正确信息。
  • 计划 2 必须显示没有加类费的员工 #1 的正确信息。
  • 计划 3-6 是计划 1 和 2 的拷贝,但针对其他员工。

计划要求:

  • 定义一个用于整个程序的基类。
  • 该类包含与加类费计算相关的函数调用和变量。
  • 为每位员工定义一个对象。请注意,将有三名员工。
  • 您的程序必须使用创建的对象并根据总工资、总小时数和加类总小时数进行计算。请参阅示例输出的员工摘要数据部分。

完成程序的逻辑步骤:

  • 定义您的基类。
  • 从您的基类定义您的对象。
  • 提示用户输入,为所有三个用户更新您的对象类。
  • 计算加类费。
  • 显示加类或正常时间的工资计算。请参阅下面的示例输出。
  • 通过汇总您的员工对象并在下面的示例中显示汇总信息来实现对象计算。

这是代码:

    // Final_Project.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

//
//CLASS DECLARATION SECTION
//
class CEmployee
{
public:
void ImplementCalculations(string EmployeeName, double hours, double wage);
void DisplayEmployInformation(void);
void Addsomethingup (CEmployee, CEmployee, CEmployee);
string EmployeeName ;
int hours ;
int overtime_hours ;
int iTotal_hours ;
int iTotal_OvertimeHours ;
float wage ;
float basepay ;
float overtime_pay ;
float overtime_extra ;
float iTotal_salaries ;
float iIndividualSalary ;
};

int main()
{ system("cls");

cout << "Welcome to the Employee Pay Center";

/*
Use this section to define your objects. You will have one object per employee. You have only three employees.
The format is your class name and your object name.
*/


std::cout << "Please enter Employee's Name: ";
std::cin >> EmployeeName;
std::cout << "Please enter Total Hours for (EmployeeName): ";
std::cin >> hours;
std::cout << "Please enter Base Pay for(EmployeeName): ";
std::cin >> basepay;
/*
Here you will prompt for the first employee’s information.
Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
Example of Prompts
Enter the employee name =
Enter the hours worked =
Enter his or her hourly wage =
*/

/*
Here you will prompt for the second employee’s information.
Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
Enter the employee name =
Enter the hours worked =
Enter his or her hourly wage =

*/

/*
Here you will prompt for the third employee’s information.
Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
Enter the employee name =
Enter the hours worked =
Enter his or her hourly wage =

*/

/*
Here you will implement a function call to implement the employ calcuations for each object defined above. You will do this for each of the three employees or objects.
The format for this step is the following:
[(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
*/

/*
This section you will send all three objects to a function that will add up the the following information:
- Total Employee Salaries
- Total Employee Hours
- Total Overtime Hours

The format for this function is the following:
- Define a new object.
- Implement function call [objectname.functionname(object name 1, object name 2, object name 3)]
/*

} //End of Main Function


void CEmployee::ImplementCalculations (string EmployeeName, double hours, double wage){
//Initialize overtime variables
overtime_hours=0;
overtime_pay=0;
overtime_extra=0;

if (hours > 40)
{

/*
This section is for the basic calculations for calculating overtime pay.
- base pay = 40 hours times the hourly wage
- overtime hours = hours worked – 40
- overtime pay = hourly wage * 1.5
- overtime extra pay over 40 = overtime hours * overtime pay
- salary = overtime money over 40 hours + your base pay
*/

/*
Implement function call to output the employee information. Function is defined below.
*/


} // if (hours > 40)
else
{

/* Here you are going to calculate the hours less than 40 hours.
- Your base pay is = your hours worked times your wage
- Salary = your base pay
*/

/*
Implement function call to output the employee information. Function is defined below.
*/

} // End of the else

} //End of Primary Function

void CEmployee::DisplayEmployInformation();
{
// This function displays all the employee output information.

/*
This is your cout statements to display the employee information:
Employee Name ............. =
Base Pay .................. =
Hours in Overtime ......... =
Overtime Pay Amount........ =
Total Pay ................. =
*/

} // END OF Display Employee Information

void CEmployee::Addsomethingup (CEmployee Employ1, CEmployee Employ2)
{
// Adds two objects of class Employee passed as
// function arguments and saves them as the calling object's data member values.

/*
Add the total hours for objects 1, 2, and 3.
Add the salaries for each object.
Add the total overtime hours.
*/

/*
Then display the information below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 576.43
%%%% Total Employee Hours ........ = 108
%%%% Total Overtime Hours......... = 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
} // End of function

最佳答案

不要 float 用于财务数据,永远

这会让您遇到各种舍入和精度问题,并且您不希望它们出现在描述货币总和的数据中。除非你喜欢被起诉,当然 :)。

使用整数类型或创建定点类型。

此外,如果可能,不要使用 system()。这本质上是不可移植的,更不用说又慢又丑了。

在您填写更多代码之前,这就是我能告诉您的全部内容。祝你好运!

关于c++ - 我在使用 Microsoft Visual C++ 进行 C++ 作业时需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2484931/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com