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

Write a C++ program to read from each line of the input file an employee identif

ID: 3621263 • Letter: W

Question

Write a C++ program to read from each line of the input file an employee identification number (in integer), the hours worked, and the number of dependents. Each employee is paid $10.50 per hour for regular hours and $15.25 per hour for overtime hours.From the worker's gross pay, 8% is withheld for social security tax, 15% is withheld for federal income tax, and 7% is withheld for state income tax. If the worker has four or more dependents, then an additional $35 is withheld to cover the extra cost of medical insurance.
Requirements:
1. Use setw and setprecision as well as oisflags
2. Use a sentinel- controlled while loop.

Explanation / Answer

please rate - thanks

you weren't specific -what is the sentinel to be used?

how many hours for overtime?

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{int id,hours,dep,other;
double gross,fed,state,ss,net;
ifstream in;
cout<<setiosflags(ios::showpoint);
cout<<setiosflags(ios::fixed);
in.open("input.txt");           //open file
if(in.fail())             //is it ok?
   { cout<<"file did not open please check it ";
    system("pause");
    return 1;
    }
cout<<"       hours depen- gross ss fed state net ";
cout<<"id   worked dents tax pat tax tax other pay ";
in>>id;
while(id!=0)
{in>>hours>>dep;
if(hours<=40)
    gross=hours*10.5;
else
    gross=40*10.5+(hours-40)*15.25;
ss=gross*.08;
fed=gross*.15;
state=gross*.07;
if(dep>=4)
   other=35;
else
    other=0;
net=gross-ss-state-fed-other;
cout<<id<<setw(7)<<hours<<setw(12)<<dep<<setw(9)<<setprecision(2)<<
     gross<<setw(8)<<setprecision(2)<<ss<<setw(8)<<setprecision(2)
     <<fed<<setw(8)<<setprecision(2)<<state<<setw(8)<<setprecision(2)
     <<other<<setw(9)<<setprecision(2)<<net<<endl;   
in>>id;
}   
in.close();
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