Your program data must accept or receive the data (input data) from the keyboard
ID: 3832415 • Letter: Y
Question
Your program data must accept or receive the data (input data) from the keyboard.
regularHours
overtimeHours
basePayRate
overtimePayRate
You must output (cout) messages to let the user know when to enter or read the appropriate data in.
You must output/display a report in the following order:
Title of your output: “Employee’s Payment Report”
In a well spaced and column-wise display
The name of the input data item followed by a colon, then followed by the actual value.
Use the stream manipulator directives to display the data with not more than two digits after the decimal point.
Example:
Regular hour worked: xx
Overtime hours worked: xx
Base Payrate: xxx.xx
Overtime Payrate: xxx.xx
(and so on…)
Then your output values must follow:
Regular wages: xxx.xx
Overtime wages: xxx.xx
Total wages: xxx.xx
Use the setw(), setprecision(), fixed, showpoint to obtain suggested printout.
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int regularHours , overtimHours;
double baseRate, overtimeRate;
cout<<"Enter Regular hour worked: ";
cin >> regularHours;
cout<<"Enter Overtime hours worked: ";
cin >> overtimHours;
cout<<"Enter Base Payrate: ";
cin >> baseRate;
cout<<"Overtime Payrate: ";
cin >> overtimeRate;
double regulareWages = regularHours * baseRate;
double overtimeWages = overtimHours * overtimeRate;
double totalWages = regulareWages + overtimeWages;
cout<<"Employee’s Payment Report"<<endl;
cout<<fixed<<setprecision(2)<<"Regular wages: "<<regulareWages<<endl;
cout<<fixed<<setprecision(2)<<"Overtime wages: "<<overtimeWages<<endl;
cout<<fixed<<setprecision(2)<<"Total wages: "<<totalWages<<endl;
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Enter Regular hour worked: 10
Enter Overtime hours worked: 5
Enter Base Payrate: 5.5
Overtime Payrate: 8.8
Employee’s Payment Report
Regular wages: 55.00
Overtime wages: 44.00
Total wages: 99.00
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.