Write a program that calculatesand prints the monthly paycheck for an employee.
ID: 3623700 • Letter: W
Question
Write a program that calculatesand prints the monthly paycheck for an employee. the net pay is calculated after taking the following deductions:federal income tax: 15%, state tax; 3.5%, social security tax: 5.75%, medicare/medicaid tax: 2.75%, pension plan: 5%, health insurance: $75.00
the program should prompt the user to input the gross amount and the employee name. the output will be store in a file . format the output to have two decimal places... I did this part of the program... now i have to updated to the following conditions... Please help me i just dont get it!!! i try to use the while loops but the program did not work help me please!!!
1. Your program should prompt the user to specify the input file (indata.txt) which contains unknown number of pairs of gross amount and employee-name such as:
3575.00 Bill Robinson
2500.23 John Smith
2533.37 Ave Winestein
1759.84 Frank Ho
3223.75 Simon Peters
2. Your program also prompt the user to specify the file where
the output should be stored.
3. Your program will fetch the information from the input file
for each employee and print a paycheck for the employee in
the output file, by using the same deduction scheme and the
same output format you used in the previous program and
using a line to separate two paychecks.
Explanation / Answer
please rate - thanks
#include <iostream>
#include <fstream>
#include<iomanip>
using namespace std;
int main()
{ifstream in;
ofstream out;
string name;
double gross,fed,state,ss,med,pen,health,tot;
char filename[20];
cout<<"Enter input file name: ";
cin>>filename;
in.open(filename);
if(in.fail())
{ cout<<"input file did not open please check it ";
system("pause");
return 1;
}
cout<<"Enter output file name: ";
cin>>filename;
out.open(filename);
out<<setprecision(2)<<fixed;
in>>gross;
while(in)
{getline(in,name);
fed=gross*.15;
state=gross*.035;
ss=gross*.0575;
med=gross*.0275;
pen=gross*.05;
health=75;
tot= fed+state+ss+med+pen+health;
out<<setw(30)<<left<<"Employee Name: "<<name<<endl;
out<<setw(30)<<left<<"Gross Pay: $"<<gross<<endl<<endl;
out<<setw(30)<<left<<"Deductions ---------- ";
out<<setw(30)<<left<<"Federal Income tax: $"<<fed<<endl;
out<<setw(30)<<left<<"State tax: $"<<state<<endl;
out<<setw(30)<<left<<"Social Security tax: $"<<ss<<endl;
out<<setw(30)<<left<<"Medicare/Medicaid: $"<<med<<endl;
out<<setw(30)<<left<<"Pension plan: $"<<pen<<endl;
out<<setw(30)<<left<<"Health: $"<<health<<endl<<endl;
out<<setw(30)<<left<<"Total Deductions: $"<<tot<<endl;
out<<"-------------- ";
tot=gross-tot;
out<<setw(30)<<left<<"Net Pay: $"<<tot<<endl<<endl;
out<<"------------------------------------------------------------------ ";
in>>gross;
}
in.close();
out.close();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.