Emp2.1工资; 3.3小时; cout>Emp3.1工资; 不能,c++,C++" /> Emp2.1工资; 3.3小时; cout>Emp3.1工资; 不能,c++,C++" />

我的代码有困难吗 我正在学习C++课程,我必须建立一个工资系统。我很难找出我的代码出了什么问题。我可以让员工花几个小时来制作,但我现在的代码有了新的问题。我认为这是正确的,但我猜不是。现在的新问题是,我可以让员工的工作时间产生,但当我这样做时,我的代码希望将我的加班时间乘以3,并产生一个拥有两次加班时间的人的输出 #include <iostream> #include <string> #include <iomanip> using namespace std; // //CLASS DECLARATION SECTION // class EmployeeClass { public: void ImplementCalculations(string EmployeeName, int hours, float wage); void DisplayEmployInformation(void); void Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3); string EmployeeName; int hours ; float wage ; float basepay ; int overtime_hours ; float overtime_pay ; float overtime_extra ; float iTotal_salaries ; float iIndividualSalary ; int iTotal_hours ; int iTotal_OvertimeHours ; }; int main() { system("cls"); cout << "\nWelcome to Data Max Inc. Employee Pay Center\n\n" ; EmployeeClass Emp1; EmployeeClass Emp2; EmployeeClass Emp3; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "\n\nEnter the first employee's first name = "; cin >> Emp1.EmployeeName; cout << "\n\nEnter the hours worked = "; cin >> Emp1.hours; cout << "\n\nEnter employee's hourly wage = "; cin >> Emp1.wage; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "\n\nEnter the second employee's first name = "; cin >> Emp2.EmployeeName; cout << "\n\nEnter the hours worked = "; cin >> Emp2.hours; cout << "\n\nEnter employee's hourly wage = "; cin >> Emp2.wage; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "\n\nEnter the third employee's first name = "; cin >> Emp3.EmployeeName; cout << "\n\nEnter the hours worked = "; cin >> Emp3.hours; cout << "\n\nEnter employee's hourly wage = "; cin >> Emp3.wage; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << endl; Emp1.ImplementCalculations(Emp1.EmployeeName, Emp1.hours, Emp1.wage); Emp2.ImplementCalculations(Emp2.EmployeeName, Emp2.hours, Emp2.wage); Emp3.ImplementCalculations(Emp3.EmployeeName, Emp3.hours, Emp3.wage); cin.get(); return 0; } //End of Main Function void EmployeeClass::ImplementCalculations (string employeeFirstName, int hours, float wage){ //Initialize overtime variables overtime_hours=0; overtime_pay=0; overtime_extra=0; if (hours > 40) { basepay = 40 * wage; overtime_hours = hours - 40; overtime_pay = wage * 1.5; overtime_extra = overtime_hours * overtime_pay; iIndividualSalary = overtime_extra + basepay; DisplayEmployInformation(); } // if (hours > 40) else { basepay = hours * wage; iIndividualSalary = basepay; } // End of the else DisplayEmployInformation(); } //End of Primary Function void EmployeeClass::DisplayEmployInformation () { // This function displays all the employee output information. cout << "\n\n"; cout << "Employee First Name ............. = " << EmployeeName << endl; cout << "Base Pay ........................ = " << basepay << endl; cout << "Hours in Overtime ............... = " << overtime_hours << endl; cout << "Overtime Pay Amout............... = " << overtime_extra << endl; cout << "Total Pay ....................... = " << iIndividualSalary << endl; } // END OF Display Employee Information void EmployeeClass::Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3){ iTotal_salaries = 0; iTotal_hours = 0; iTotal_OvertimeHours = 0; iTotal_hours = Emp1.hours + Emp2.hours + Emp3.hours; iTotal_salaries = iIndividualSalary + iIndividualSalary + iIndividualSalary; iTotal_OvertimeHours = overtime_hours + overtime_hours + overtime_hours; cout << "\n\n"; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%% Total Employee Salaries ..... = " << iTotal_salaries << endl; cout << "%%%% Total Employee Hours ........ = " << iTotal_hours << endl; cout << "%%%% Total Overtime Hours......... = " << iTotal_OvertimeHours << endl; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; } // End of function #包括 #包括 #包括 使用名称空间std; // //班级申报组 // 阶级雇员阶级{ 公众: 无效计算(字符串EmployeeName、整数小时、浮动工资); 作废显示员工信息(作废); void Addsomethingup(EmployeeClass Emp1、EmployeeClass Emp2、EmployeeClass Emp3); 字符串EmployeeName; 整小时; 浮动工资; 浮动基本工资; 国际加班时间; 浮动加班费; 浮动加班费; 浮动工资; 浮动式个人日历; 国际总时数; 国际总时间超过小时; }; int main() {系统(“cls”); 1.工资; 2.2小时; cout>Emp2.1工资; 3.3小时; cout>Emp3.1工资; 不能

我的代码有困难吗 我正在学习C++课程,我必须建立一个工资系统。我很难找出我的代码出了什么问题。我可以让员工花几个小时来制作,但我现在的代码有了新的问题。我认为这是正确的,但我猜不是。现在的新问题是,我可以让员工的工作时间产生,但当我这样做时,我的代码希望将我的加班时间乘以3,并产生一个拥有两次加班时间的人的输出 #include <iostream> #include <string> #include <iomanip> using namespace std; // //CLASS DECLARATION SECTION // class EmployeeClass { public: void ImplementCalculations(string EmployeeName, int hours, float wage); void DisplayEmployInformation(void); void Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3); string EmployeeName; int hours ; float wage ; float basepay ; int overtime_hours ; float overtime_pay ; float overtime_extra ; float iTotal_salaries ; float iIndividualSalary ; int iTotal_hours ; int iTotal_OvertimeHours ; }; int main() { system("cls"); cout << "\nWelcome to Data Max Inc. Employee Pay Center\n\n" ; EmployeeClass Emp1; EmployeeClass Emp2; EmployeeClass Emp3; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "\n\nEnter the first employee's first name = "; cin >> Emp1.EmployeeName; cout << "\n\nEnter the hours worked = "; cin >> Emp1.hours; cout << "\n\nEnter employee's hourly wage = "; cin >> Emp1.wage; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "\n\nEnter the second employee's first name = "; cin >> Emp2.EmployeeName; cout << "\n\nEnter the hours worked = "; cin >> Emp2.hours; cout << "\n\nEnter employee's hourly wage = "; cin >> Emp2.wage; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "\n\nEnter the third employee's first name = "; cin >> Emp3.EmployeeName; cout << "\n\nEnter the hours worked = "; cin >> Emp3.hours; cout << "\n\nEnter employee's hourly wage = "; cin >> Emp3.wage; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << endl; Emp1.ImplementCalculations(Emp1.EmployeeName, Emp1.hours, Emp1.wage); Emp2.ImplementCalculations(Emp2.EmployeeName, Emp2.hours, Emp2.wage); Emp3.ImplementCalculations(Emp3.EmployeeName, Emp3.hours, Emp3.wage); cin.get(); return 0; } //End of Main Function void EmployeeClass::ImplementCalculations (string employeeFirstName, int hours, float wage){ //Initialize overtime variables overtime_hours=0; overtime_pay=0; overtime_extra=0; if (hours > 40) { basepay = 40 * wage; overtime_hours = hours - 40; overtime_pay = wage * 1.5; overtime_extra = overtime_hours * overtime_pay; iIndividualSalary = overtime_extra + basepay; DisplayEmployInformation(); } // if (hours > 40) else { basepay = hours * wage; iIndividualSalary = basepay; } // End of the else DisplayEmployInformation(); } //End of Primary Function void EmployeeClass::DisplayEmployInformation () { // This function displays all the employee output information. cout << "\n\n"; cout << "Employee First Name ............. = " << EmployeeName << endl; cout << "Base Pay ........................ = " << basepay << endl; cout << "Hours in Overtime ............... = " << overtime_hours << endl; cout << "Overtime Pay Amout............... = " << overtime_extra << endl; cout << "Total Pay ....................... = " << iIndividualSalary << endl; } // END OF Display Employee Information void EmployeeClass::Addsomethingup (EmployeeClass Emp1, EmployeeClass Emp2, EmployeeClass Emp3){ iTotal_salaries = 0; iTotal_hours = 0; iTotal_OvertimeHours = 0; iTotal_hours = Emp1.hours + Emp2.hours + Emp3.hours; iTotal_salaries = iIndividualSalary + iIndividualSalary + iIndividualSalary; iTotal_OvertimeHours = overtime_hours + overtime_hours + overtime_hours; cout << "\n\n"; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%% Total Employee Salaries ..... = " << iTotal_salaries << endl; cout << "%%%% Total Employee Hours ........ = " << iTotal_hours << endl; cout << "%%%% Total Overtime Hours......... = " << iTotal_OvertimeHours << endl; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl; } // End of function #包括 #包括 #包括 使用名称空间std; // //班级申报组 // 阶级雇员阶级{ 公众: 无效计算(字符串EmployeeName、整数小时、浮动工资); 作废显示员工信息(作废); void Addsomethingup(EmployeeClass Emp1、EmployeeClass Emp2、EmployeeClass Emp3); 字符串EmployeeName; 整小时; 浮动工资; 浮动基本工资; 国际加班时间; 浮动加班费; 浮动加班费; 浮动工资; 浮动式个人日历; 国际总时数; 国际总时间超过小时; }; int main() {系统(“cls”); 1.工资; 2.2小时; cout>Emp2.1工资; 3.3小时; cout>Emp3.1工资; 不能,c++,C++,您没有在任何地方调用Addsomethingup。您可能还希望这是一种静态方法。如果您还没有了解它们是什么,请不要担心 在main函数的末尾,但在cin.get()之前,尝试添加: Emp1.Addsomethingup(Emp1, Emp2, Emp3); 更好的做法是让类方法返回一个字符串,然后从main打印出来。您能告诉我们到底发生了什么吗?您是否得到错误跟踪或意外输出?请具体说明。我根本没有收到任何错误。就我的输出而言,我没有得到任何关于我的员工数据摘要的信息。我能够我会计算出3个员工

您没有在任何地方调用
Addsomethingup
。您可能还希望这是一种
静态方法。如果您还没有了解它们是什么,请不要担心

main
函数的末尾,但在
cin.get()
之前,尝试添加:

Emp1.Addsomethingup(Emp1, Emp2, Emp3);

更好的做法是让类方法返回一个
字符串
,然后从main打印出来。您能告诉我们到底发生了什么吗?您是否得到错误跟踪或意外输出?请具体说明。我根本没有收到任何错误。就我的输出而言,我没有得到任何关于我的员工数据摘要的信息。我能够我会计算出3个员工的工作时数、工资和加班时数,但我无法计算出所有3个员工的总工作时数、总工资和加班时数。谢谢你们,谢谢你们,再次谢谢你们。这就是我需要的。你们帮了我大忙