fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5. using std::cout;
  6. //
  7. //CLASS DECLARATION SECTION
  8. //
  9. class EmployeeClass {
  10. public:
  11. void ImplementCalculations(string EmployeeName, int hours, float wage);
  12. void DisplayEmployInformation();
  13. void Addsomethingup(EmployeeClass, EmployeeClass, EmployeeClass);
  14. string EmployeeName;
  15. int hours;
  16. float wage;
  17. float basepay;
  18. int overtime_hours;
  19. float overtime_pay;
  20. float overtime_extra;
  21. float iTotal_salaries;
  22. float iIndividualSalary;
  23. int iTotal_hours;
  24. int iTotal_OvertimeHours;
  25. };
  26. EmployeeClass Employ1;
  27. EmployeeClass Employ2;
  28. EmployeeClass Employ3;
  29. int main()
  30. {
  31. system("cls");
  32. // display welcome information
  33. cout << "\nWelcome to the Employee Pay Center\n\n";
  34. /*
  35.   Use this section to define your objects. You will have one object per employee. You have only three employees.
  36.   The format is your class name and your object name.
  37.   */
  38. /*
  39.   Here you will prompt for the first employee’s information.
  40.   Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
  41.   Example of Prompts
  42.   Enter the employee name =
  43.   Enter the hours worked =
  44.   Enter his or her hourly wage =
  45.   */
  46. // Enter employees information
  47. cout << "Enter the first employee's name = ";
  48. cin >> Employ1.EmployeeName;
  49. cout << "\nEnter the hours worked = ";
  50. cin >> Employ1.hours;
  51. cout << "\nEnter his or her hourly wage = ";
  52. cin >> Employ1.wage;
  53. /*
  54.   Here you will prompt for the second employee’s information.
  55.   Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
  56.   Enter the employee name =
  57.   Enter the hours worked =
  58.   Enter his or her hourly wage =
  59.   */
  60. cout << "\nEnter the second employee's name = ";
  61. cin >> Employ2.EmployeeName;
  62. cout << "\nEnter the hours worked = ";
  63. cin >> Employ2.hours;
  64. cout << "\nEnter his or her hourly wage = ";
  65. cin >> Employ2.wage;
  66. /*
  67.   Here you will prompt for the third employee’s information.
  68.   Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
  69.   Enter the employee name =
  70.   Enter the hours worked =
  71.   Enter his or her hourly wage =
  72.   */
  73. cout << "\nEnter the third employee's name = ";
  74. cin >> Employ3.EmployeeName;
  75. cout << "\nEnter the hours worked = ";
  76. cin >> Employ3.hours;
  77. cout << "\nEnter his or her hourly wage = ";
  78. cin >> Employ3.wage;
  79. /*
  80.   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.
  81.   The format for this step is the following:
  82.   [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
  83.   */
  84. cout << endl;
  85. Employ1.ImplementCalculations(Employ1.EmployeeName, Employ1.hours, Employ1.wage);
  86. Employ2.ImplementCalculations(Employ2.EmployeeName, Employ2.hours, Employ2.wage);
  87. Employ3.ImplementCalculations(Employ3.EmployeeName, Employ3.hours, Employ3.wage);
  88. } // return 0;
  89. void EmployeeClass::ImplementCalculations(string EmployeeName, int hours, float wage)
  90. {
  91. //Initialize overtime variables
  92. overtime_hours = 0;
  93. overtime_pay = 0.0;
  94. overtime_extra = 0.0;
  95. if (hours > 40)// calculate overtime if hours greater than 40
  96. {
  97. basepay = (40 * wage);
  98. overtime_hours = hours - 40;
  99. overtime_pay = wage * 1.5;
  100. overtime_extra = overtime_hours * overtime_pay;
  101. iIndividualSalary = (overtime_extra + basepay);
  102. DisplayEmployInformation();
  103. }
  104. // if (hours > 40)
  105. else
  106. {
  107. basepay = hours * wage;
  108. iIndividualSalary = overtime_pay + basepay;
  109. DisplayEmployInformation();
  110. }
  111. } //End of Primary Function
  112. void EmployeeClass::DisplayEmployInformation()
  113. // This function displays all the employee output information.
  114. {
  115. cout << "\n\n";
  116. cout << "Employee Name ......................... " << EmployeeName << endl;
  117. cout << "Base Pay .............................. " << basepay << endl;
  118. cout << "Hours in Overtime ..................... " << overtime_hours << endl;
  119. cout << "Overtime Pay Amount ................... " << overtime_hours * overtime_pay << endl;
  120. cout << "Total Pay ............................. " << iIndividualSalary << endl;
  121. Addsomethingup(Employ1,Employ2,Employ3);
  122. }// END OF Display Employee Information
  123. void EmployeeClass::Addsomethingup(EmployeeClass Employ1, EmployeeClass Employ2, EmployeeClass Employ3)
  124. {
  125. // Adds three objects of class Employee passed as
  126. // function arguments and saves them as the calling object's data member values.
  127. /*
  128.   Add the total hours for objects 1, 2, and 3.
  129.   Add the salaries for each object.
  130.   Add the total overtime hours.
  131.   */
  132. iTotal_hours = Employ1.hours + Employ2.hours + Employ3.hours;
  133. iTotal_salaries = Employ1.iIndividualSalary + Employ2.iIndividualSalary + Employ3.iIndividualSalary;
  134. iTotal_OvertimeHours = Employ1.overtime_hours + Employ2.overtime_hours + Employ3.overtime_hours;
  135. /*
  136.   Then display the information below.
  137.   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  138.   %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
  139.   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  140.   %%%% Total Employee Salaries ..... = 576.43
  141.   %%%% Total Employee Hours ........ = 108
  142.   %%%% Total Overtime Hours......... = 5
  143.   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  144.   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  145.   */
  146. cout << endl;
  147. cout << "%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%" << endl;
  148. cout << endl;
  149. cout << "%%%% Total Employee Salaries ........ = " << iTotal_salaries << endl;
  150. cout << "%%%% Total Employee Hours ........... = " << iTotal_hours << endl;
  151. cout << "%%%% Total Overtime Hours ........... = " << iTotal_OvertimeHours << endl;
  152. cout << endl;
  153. // End of function
  154. };
Success #stdin #stdout #stderr 0s 3352KB
stdin
Standard input is empty
stdout
Welcome to the Employee Pay Center

Enter the first employee's name      = 
Enter the hours worked               = 
Enter his or her hourly wage         = 
Enter the second employee's name      = 
Enter the hours worked                = 
Enter his or her hourly wage          = 
Enter the third employee's name      = 
Enter the hours worked               = 
Enter his or her hourly wage         = 


Employee Name ......................... 
Base Pay .............................. 0
Hours in Overtime ..................... 0
Overtime Pay Amount ................... 0
Total Pay ............................. 0

%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ........ = 0
%%%% Total Employee Hours ........... = 0
%%%% Total Overtime Hours ........... = 0



Employee Name ......................... 
Base Pay .............................. 0
Hours in Overtime ..................... 0
Overtime Pay Amount ................... 0
Total Pay ............................. 0

%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ........ = 0
%%%% Total Employee Hours ........... = 0
%%%% Total Overtime Hours ........... = 0



Employee Name ......................... 
Base Pay .............................. 0
Hours in Overtime ..................... 0
Overtime Pay Amount ................... 0
Total Pay ............................. 0

%%%%%%%%%%%%%%%% EMPLOYEE SUMMARY DATA %%%%%%%%%%%%%%%%

%%%% Total Employee Salaries ........ = 0
%%%% Total Employee Hours ........... = 0
%%%% Total Overtime Hours ........... = 0

stderr
sh: cls: not found