Write a program that calculates weekly payment. The program will ask the user fu
ID: 672548 • Letter: W
Question
Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate. For example if the user’s hourly rate is $15 and worked for 48 hours, the additional 8 hours will be paid at $22.50/hour. Use 5% as tax deduction. The program will calculate and display the net payment. The following is a sample of the program output: Enter your first and last name: Jane Doe ID number: E1007 Hours worked: 48.0 Hourly rate: 15.0 Name: Jane Doe ID# E1007 Hours worked: 48.00 Regular weekly hours: $600.00 Additional 8 hours worked: $180.00 Gross Pay: $780.00 5% Tax: $39.00 Net Pay: $741.00
Explanation / Answer
#include<iostream>
using namespace std;
main()
{
char id[10];
string name;
float gross,rate;
cout<<"enter your full name: ";
getline (cin, name);
int hours;
cout<<"enter your id: ";
cin>>id;
cout<<"enter the number of hours worked: ";
cin>>hours;
cout<<"enter the hourly rate: ";
cin>>rate;
int temp=hours-40,sum;
cout<<"Name: "<<name;
cout<<" ID#: "<<id;
cout<<" Hours worked: "<<hours;
gross=rate*40;
cout<<" Regular weekly hours: $"<<gross;
if(hours>40)
{
sum=temp*(1.5*rate);
cout<<" Additional "<<temp<<" hours worked: $"<<sum;
gross=sum+gross;
}
cout<<" Gross Pay: $"<<gross;
float tax;
tax=(5.00/100)*gross;
cout<<" Tax: $"<<tax;
gross=gross-tax;
cout<<" Net Pay: $"<<gross;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.