Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- int main () {
- const double TAXRATE = 0.0307, OVERTIMEV = 35.0;
- double gross, tax, net, hoursworked, hourly; //gross pay, PA taxes, Net pay, Hourly Rate, and Hours worked.
- long overtime, undertime;
- cout << fixed<<showpoint;
- //ask for data
- cout<<"--Welcome to the Penn State Wilkes-Barre Payroll program--: "<<endl;
- cout<<"Please enter data below: "<<endl;
- cout<<endl;
- cout<<"Number of hours worked: ";
- cin>>hoursworked;
- cout<<"Hourly rate of pay: ";
- cin>>hourly;
- //Making variables gp, tax, and np.
- if(hoursworked<=35.0)
- {
- undertime = hoursworked;
- overtime=0;
- gross=( hoursworked* hourly) ;
- }
- else
- {
- undertime = 35;
- overtime = (hoursworked - OVERTIMEV) * hourly * 1.5 ;
- gross= (undertime * hourly) + overtime;
- }
- tax=(gross*TAXRATE);
- net=(gross-tax);
- ofstream fout ("payroll.out");
- cout<<endl;
- cout<<"Penn State Wilkes Barre Payroll Report "<<endl;
- cout<<endl;
- cout<<setprecision(2)<<endl;
- cout<<fixed<<showpoint; //show results for equations
- cout<<"Hours Worked "<<setw(9)<<hoursworked<<endl;
- cout<<"Hourly rate "<<setw(9)<<hourly<<endl;
- cout<<"Regular pay "<<setw(9)<<undertime<<" hours at "<<hourly<<" "<<undertime<<" "<<endl;
- cout<<"Overtime pay "<<setw(9)<<hoursworked - undertime <<" hours at "<<hourly *1.5<<" "<<overtime<<" "<<endl;
- cout<<"Gross pay "<<setw(9)<<gross<<endl;
- cout<<"Pa State tax (3.07%) "<<setw(9)<<tax<<endl;
- cout<<"Net Pay "<<setw(10)<<net<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"End of Results"<<endl;
- cout<<"Your output has been sent to payroll.out"<<endl;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment