May 3, 2020 at 9:03pm UTC
I am trying to make it so the program lists the next employee as a new output table of information, but instead, it is replacing the output table from the first employee. Any help is appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
//preproccesor directives
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
//main
int main ()
{
string name;
int IDnumber, hours, classif, i, numemployees;
int overtime = 0;
double hourlyrate, amount, overtimepay = 0, regularpay;
cout << "How many employees are being logged? " ;
cin >> numemployees;
for (int i = 0; i < numemployees; i++){
//get information
cout << "Employee name: " ;
getline(cin.ignore(), name);
cout << "ID number: " ;
cin >> IDnumber;
cout << "Hours worked: " ;
cin >> hours;
cout << "Job Classification: " ;
cin >> classif;
//start switch to find hourly rate
switch (classif)
{
case 1:
hourlyrate = 5.5;
break ;
case 2:
hourlyrate = 6.0;
break ;
case 3:
hourlyrate = 7.0;
break ;
case 4:
hourlyrate = 9.0;
break ;
case 5:
hourlyrate = 12.0;
break ;
default :
hourlyrate = 5.5;
}
//if else to find overtime pay
if (hours >= 40)
{
regularpay = 40 * hourlyrate;
overtimepay = (hours-40) * 1.5 * hourlyrate;
overtime = hours - 40;
}
else
regularpay = hours * hourlyrate;
//find total amount
amount = regularpay + overtimepay;
system("CLS" );
//output
cout << "\t\tWorkHard Corporation\n" ;
cout << "\t\t____________________\n" ;
cout << "\t\t____________________\n" ;
cout << "Employee's Name : " << setw(13) << name << "\t\tId Number : " << setw(10) << IDnumber << "\n\n" ;
cout << "Job Classification : " << setw(10) << classif << "\t\tHourly Rate : " << setw(8) << hourlyrate << "\n\n" ;
cout << "Total Hours worked : " << setw(10) << hours << "\t\tOvertime Hours : " << setw(5) << overtime << "\n\n" ;
cout << "Regular Pay : " << setw(17) << regularpay << "\t\tOvertime Pay : " << setw(7) << overtimepay << "\n\n" ;
cout << "\t\tTotal earnings....... $" <<amount<<endl;
//errors that occured
if (classif > 5 | classif < 1)
cout << "\t*** The Employee's Job Classification is in error ***\n" ;
if (hours > 60)
cout << "\t*** Excessive Number of Hours worked ***\n" ;
if (hours < 40)
cout << "\t*** Inadequate Number of Hours worked ***\n" ;
cout << "\n ************************************************\n" ;
}
return 0;
}
//Calculate weekly wage for each employee
//Taking in Name, ID number, Hours worked, job type
Last edited on May 3, 2020 at 11:46pm UTC
May 3, 2020 at 11:46pm UTC
Thank you, also that was my first post clearly, thanks for teaching me about code tags.
Last edited on May 3, 2020 at 11:52pm UTC