help with my code

I have been working with this code for at least two weeks for a class. I am wondering if anyone can show me what i am doing wrong? Will be grateful for help.

Here is my assignment to show you i am trying to accomplish:
Goals:
1. Use arithmetic operators and relational operators
2. Use const keyword to declare a constant data object
3. Use if / else and switch decision constructs
4. Develop a flow chart depicting decision structures
5. Format numerical output

Description:
Calculate the weekly wage for hourly employees.

Interaction:
Enter employee number: 1032864
Enter pay code ( M/O/T ): M
Enter hours worked: 41

Example Output:
Employee #: 1032864
Pay Rate: \$5.15
Hours Worked: 41
Goals:
1. Use arithmetic operators and relational operators
2. Use const keyword to declare a constant data object
3. Use if / else and switch decision constructs
4. Develop a flow chart depicting decision structures
5. Format numerical output

Description:
Calculate the weekly wage for hourly employees.

Interaction:
Enter employee number: 1032864
Enter pay code ( M/O/T ): M
Enter hours worked: 41
Total Pay: \$213.72

Input Data:
Employee Number
Hours Worked

Pay Code:
The company has three pay scales:
minimum wage - pay code 'M'
minimum plus \$1.00 - pay code 'O'
minimum plus \$2.00 - pay code 'T'
The current minimum wage is _________. (Use the Internet...find out.)

Test Data:
Employee
Pay Code
Hours
Pay \$\$
1032864
M
41

1171955
T
38

1224096
O
45

1234567
N
40

Considerations:

Employee gets time and a half for overtime over 40 hours per week. Currency values should be formatted as currency in US dollars.
Program Logic:
// initialization
(Did you remember to #include <iomanip>?
Display Programmer Name and Assignment Number.
// input
Prompt operator for Employee Number, Pay Code, and Hours.
Store all keyboard input in data objects you declared.
// processing
Use switch to assign Pay Rate a value based on Pay Code.
If Pay Code is invalid:
Assign Pay Rate a value of zero
Display an error message to operator
Use if / else to calculate pay based on hours worked:
0 to 40 hours: multiply hours times pay rate.
Over 40 hours: multiply 40 times pay rate
multiply hours over 40 by 1½ pay rate

// output
Set precision to round pay to nearest cent.
Display results as shown above.
// termination
Display normal end of job message

other half:
PART A: do / while loop
Goals:
Modify your pay calculation program (Lab 3) to allow an unlimited number of employees to be processed:

Prompt: "Another employee to process (Y/N) ?"
Store reply and use it to control the loop.
Count the number of employees processed without error.
Accumulate a total payroll amount.
Test Data:
Use one cin statement to read all three values.
Program Interaction:

Assignment 5A Programmed by yourname here
Enter Employee #, Pay Code, Hours:
1032864 M 41
Pay Rate: \$??.?? Pay Amount: \$???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1171955 T 38
Pay Rate: \$??.?? Pay Amount: \$???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1224096 O 45
Pay Rate: \$??.?? Pay Amount: \$???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1234567 N 40
INVALID PAY CODE
Pay Rate: \$??.?? Pay Amount: \$???.??
Another employee to process (Y/N)? n
Number of Employees Processed: ?? Total Payroll: \$????.??

Normal Job Termination

and here is my code:

#include<iostream> //Header File for console I/O
#include<iomanip>

using namespace std;

const double MIN_WAGE = 15;

// begin min Function Definition
int main()
{

string employeeID;
double hoursWorked , totalPay , payRate , overTime ;
char payCode;
char again ;

// Display Identtification on screen
cout << "Assignment 5a" << endl;
cout << "Programmed by Paul Duckworth" << endl;

do
{
cout << "Enter Employee #, Pay Code, Hours:" << endl;
cin >> employeeID >> payCode >> hoursWorked ;
cout << setprecision(2) << fixed;
cout << "Pay rate: \$ " << setw(2) << payRate << " Pay Amount: \$ " << setw(2) << totalPay << endl;
cout << "add another employee? (Y/N)";
cin >> again;

if ( hoursWorked <= 40 ) {
totalPay = hoursWorked * payRate;
}
else{
cout << setprecision(2) << fixed;
overTime = hoursWorked - 40; (totalPay = 40 * payRate * hoursWorked * 1.5 + MIN_WAGE);
}

// useing switch allows user to put in paycodes
switch (payCode){
case 'm':
case 'M': payRate = MIN_WAGE;
break;

case 'o': case 'O': payRate = MIN_WAGE + 1.00;
break;
case 't':
case 'T': payRate = MIN_WAGE + 2.00;
break;
case 'n':
//case 'N':
default: cout << "you have entered the incorrect paycode" << endl;
break;

}

} while ( again == 'Y' || again == 'y');

return 0;
}

Last edited on
Move this at the end, before }while.

 ``123`` ``````cout << "Pay rate: \$ " << setw(2) << payRate << " Pay Amount: \$ " << setw(2) << totalPay << endl; cout << "add another employee? (Y/N)"; cin >> again;``````
Possibly (check calculations against requirement):

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354`` ``````#include #include using namespace std; const double MIN_WAGE {15.0}; const double NORM_HOURS {40}; int main() { char again {}; do { string employeeID; double hoursWorked {}, payRate {}; char payCode {}; cout << "Enter Employee #, Pay Code, Hours: "; cin >> employeeID >> payCode >> hoursWorked; switch (payCode) { case 'm': case 'M': payRate = MIN_WAGE; break; case 'o': case 'O': payRate = MIN_WAGE + 1.00; break; case 't': case 'T': payRate = MIN_WAGE + 2.00; break; default: cout << "you have entered the incorrect paycode\n"; break; } if (payRate) { double totalPay {hoursWorked * payRate}; if (hoursWorked > NORM_HOURS) totalPay += payRate * (hoursWorked - NORM_HOURS) * 1.5; cout << setprecision(2) << fixed; cout << "Pay rate: \$ " << setw(2) << payRate << " Pay Amount: \$ " << setw(2) << totalPay << '\n'; } cout << "add another employee? (Y/N): "; cin >> again; } while (again == 'Y' || again == 'y'); }``````
yes thanks for this guys much appreciated.
Topic archived. No new replies allowed.