This is the problem I\'m having trouble with: Write a program to calculate Net P
ID: 3532954 • Letter: T
Question
This is the problem I'm having trouble with:
Write a program to calculate Net Pay and Totals from the inputs provided below. The program should use a loop & prompt user for inputs shown.
Emp# Gross Pay Fed Tax State Tax Fica. Net Pay
2244 1650 247.50 49.50 3.30 -
2610 1800 270.00 54.00 3.60 -
2680 1470 220.50 44.10 2.94 -
2720 1660 249.00 49.80 3.32 -
2550 1500 225.00 45.00 3.10 -
I need the program to calculate the net pay of each emp# and I also need the total gross pay, fed tax, state tax, and fica.
netPay = gross - fedTax - stateTax - fica
Explanation / Answer
// you have not mentioned in which languange you want the code,
//i am posting the code in cpluspluss ,if you want this code in any other language then comment
#include<iostream>
using namespace std;
struct employee
{
char empId [10];
double grossPay;
double fedTax;
double stateTax;
double fica;
};
int main()
{
employee e[20];
int n;
cout<<"enter the no of employee ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<" enter employee no "<<i+1<<" record"<<endl<<endl;
cout<<"employee id :";
cin>>e[i].empId;
cout<<" gross pay :";
cin>>e[i].grossPay;
cout<<" fed tax: ";
cin>>e[i].fedTax;
cout<<" state tax: ";
cin>>e[i].stateTax;
cout<<" fica: ";
cin>>e[i].fica;
cout<<" ";
}
cout<<" employee record with net Pay field ";
for(int i=0;i<n;i++)
{
cout<<"EMP# :"<<e[i].empId<<endl;
cout<<"Gross pay: "<<e[i].grossPay<<endl;
cout<<"Fed tax : "<<e[i].fedTax<<endl;
cout<<"State Tax: "<<e[i].stateTax<<endl;
cout<<"Fica: "<<e[i].fica<<endl;
cout<<"Net pay :"<<e[i].grossPay-e[i].fedTax-e[i].stateTax-e[i].fica<<endl<<endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.