General Description: The Company you work for has asked you to write a program t
ID: 650558 • Letter: G
Question
General Description: The Company you work for has asked you to write a program that reads some hourly employee pay information from a file, calculates their Net Pay, and saves a report to a file.
Details:
1.The input file is called proj1data.txt, and is in the folder S:mackayCS111
2.There are only 3 hourly employees in the company, so there are only 3 lines of information in the input file
3.Each line of input contains the following information for each employee, separated by spaces:
a.First name (no spaces)
b.Last name (no spaces)
c.Hourly pay rate
d.Number of hours worked
e.Whether or not they are in the union (
Explanation / Answer
#include<iostreams.h>
#include<conio.h>
#include<fstream.h>
void main()
{
char fname[10], lname[10];
float hr_rate, nohrwk, netsal=0,grsal=0;
char umem, ins;
int i;
ifstream inf("proj1dat.txt");
ofstream outf("projout.txt");
clrscr();
for(i=1;i<=3;i++)
{
inf>>fname;
inf>>lname;
inf>>hr_rate;
inf>>nohrwk;
inf>>umem;
inf>>ins;
grsal= (hr_rate*nohrwk);
if(umem=='Y')
{
grsal=grsal-24;
}
if(ins=='Y')
{
netsal=grsal-10.36;
}
cout<<" ";
cout<<"Net Salary is :"<<grsal<<" ";
outf<<fname;
outf<<lname;
outf<<grsal;
outf<<"24";
outf<<"10.36";
outf<<grsal;
outf<<" ";
}
inf.close();
outf.close();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.