Write a program that displays a weekly payroll report. Code a loop that asks use
ID: 3655346 • Letter: W
Question
Write a program that displays a weekly payroll report. Code a loop that asks user fro employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop terminates when 0 is entered for the employee number. After all data are entered display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input validation: Do not accept negative numbers for any items entered. Do not accept values for state tax, federal tax, or FICA withholdings that are greater than gross pay for any employee; if the sum federal tax + state tax + FICA withholdings is greater than gross pay, print an error message that asks the user to re-enter the data for that employee. Please include pseudocode and data dictionaryExplanation / Answer
please rate - thanks #include <iostream>using namespace std;
int main()
{int id;
double gross,state,fed,fica;
cout<<"Enter employee ID (0 to exit): ";
cin>>id;
while(id>0)
{do
{
cout<<"Enter gross pay: ";
cin>>gross;
while(gross<0)
{cout<<"Must be >=0 ";
cout<<"Enter gross pay: ";
cin>>gross;
}
cout<<"Enter state tax: ";
cin>>state;
while(state<0||state>gross)
{cout<<"Must be >=0 and <gross ";
cout<<"Enter state tax: ";
cin>>state;
}
cout<<"Enter federal tax: ";
cin>>fed;
while(fed<0||fed>gross)
{cout<<"Must be >=0 and <gross ";
cout<<"Enter fed tax: ";
cin>>fed;
}
cout<<"Enter FICA: ";
cin>>fica;
while(fica<0||fica>gross)
{cout<<"Must be >=0 and <gross ";
cout<<"FICA: ";
cin>>fica;
}
if(state+fed+fica>gross)
cout<<"Taxes cannot be greater then salary-start over ";
}while(state+fed+fica>gross);
cout<<" Enter employee ID (0 to exit): ";
cin>>id;
}
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.