Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in C++ that displays a weekly payroll report. A loop in the prog

ID: 3624770 • Letter: W

Question

Write a program in C++ that displays a weekly payroll report. A loop in the program should ask the user for the emplyee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when ) is entered for the emplyee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay.

Do not accept negative numbers or values for state, federal or FICA withholdings that are greater than the gross pay. Print a error message is the sum of state tax=federal tax= FICA withholdings is greater than gross pay.

Explanation / Answer

#include "stdafx.h"

#include<iostream>

#include<string>

using namespace std;

int main(int argc, char* argv[])

{

string empid;

double gross_pay,state_tax,federal_tax,fica;

do

{

cout<<" Enter Employee ID: ";

cin>>empid;

if(empid==")")

exit(0);

cout<<"Enter gross pay: ";

cin>>gross_pay;

cout<<"Enter State Tax: ";

cin>>state_tax;

while(state_tax<0)

{

cout<<" state tax value should be positive.";

cout<<" Enter State Tax: ";

cin>>state_tax;

}

cout<<"Enter Federal Tax: ";

cin>>federal_tax;

while(federal_tax<0)

{

cout<<" federal tax value should be positive.";

cout<<" Enter Federal Tax: ";

cin>>federal_tax;

}

cout<<"Enter FICA: ";

cin>>fica;

while(fica<0)

{

cout<<" fica value should be positive.";

cout<<" Enter FICA: ";

cin>>fica;

}

if(gross_pay<(state_tax+federal_tax+fica))

{

cout<<" gross pay should be greater than the sum of state,federal taxes and FICA";

continue;

}

cout<<" Employee ID: "<<empid<<endl;

cout<<"Gross Pay: "<<gross_pay<<endl;

cout<<"State Tax: "<<state_tax<<endl;

cout<<"Federal Tax: "<<federal_tax<<endl;

cout<<"FICA: "<<fica<<endl;

cout<<"Net Pay: "<<(gross_pay-(state_tax+federal_tax+fica))<<endl;

}while(true);

system("pause");

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote