qstn: Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholding. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay,state tax, federal tax, FICA withholdings, and net pay.
Input validation: Do not accept negative numbers for anything. Do not accept values for state, federal or FICA withholdings that are greater than the gross pay. If it happens, show an error message and ask the user to re-enter everything..
*this is how I tried to solve it, but it ain't working. What should I do and what is wrong??:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int employeeNum;
double grosspay, state_tax,federal_tax,fica,net_pay;
cout<<"employee nmbr:\n";
cin>>employeeNum;
while (employeeNum!=0)
{
for(int employee=1;employee<=employeeNum;employee++)
{
while(grosspay>0)
{
cout<<"grosspay:\n";
cin>>grosspay;
while(state_tax>0 && state_tax<1)
{
cout<<"state tax:\n";
cin>>state_tax;
state_tax*=grosspay;
while(federal_tax>0 && federal_tax<1)
{
cout<<"federal tax:\n";
cin>>federal_tax;
federal_tax*=grosspay;
while(fica>0 && fica<1)
{
cout<<"FICA:\n";
cin>>fica;
fica*=grosspay;
}
}
}
}
cout<<"Grosspay for employee number"<<employee<<"is $"<<grosspay;
cout<<". His state tax is "<<state_tax<<" federal tax is "<<federal_tax;
cout<<"FICA withholding is "<<fica;
while(net_pay>0)
{
net_pay=grosspay-(state_tax+federal_tax+fica);
}
cout<<"Net pay for Employee"<<employee<<"is =$"<<net_pay;
}
}
return 0;
}