All pastes #2110084 Raw Edit

Unnamed

public text v1 · immutable
#2110084 ·published 2012-02-06 04:41 UTC
rendered paste body
                                
#include<iostream>
#include<iomanip>
using namespace std;

void load(char *first,char *last,float &hrs,float &rate, float &ftax,float &stax)
{
	const int size=80;
	cout<<"Enter first name:"<<endl;
	cin.getline(first,size);
	cout<<"Enter last name:"<<endl;
	cin.getline(last,size);
	cout<<"Enter the hours worked,hourly rate,Federal tax rate,and the State tax rate:"<<endl;
	cin>>hrs>>rate>>ftax>>stax;
}
void calc(float &gross,float &fowed,float &sowed,float &net,float &tgross,
	float &tfowed,float &tsowed,float &tnet,float hrs,float rate,float stax,float ftax)
{
	gross=hrs*rate;
	fowed=gross*(ftax/100);
	sowed=gross*(stax/100);
	net=gross-fowed-sowed;
	tgross+=gross;
	tfowed+=fowed;
	tsowed+=sowed;
	tnet+=net;
}
void print(char* first,char* last,float gross,float fowed,float sowed,float net)
{
	cout<<"Name"<<setw(10)<<"Gross Pay"<<setw(10)<<"Federal Tax Owed"<<setw(10)<<"State Tax Owed"<<setw(10)<<"Net Pay"<<endl;
	cout<<first<<setw(10)<<last<<setw(10)<< setprecision(2) << showpoint << fixed<<"$"<<gross<<setw(10)<<"$"<<fowed<<setw(10)<<"$"<<sowed<<setw(10)<<"$"<<net<<endl;
	cin.ignore(40,'\n');
}
int main()
{
	char first[10],last[10];
	float gross=0,fowed=0,sowed=0,net=0,hrs=0,rate=0,stax=0,ftax=0;
	float tgross=0,tfowed=0,tsowed=0,tnet=0;

	for (int i=1;i<=4;i++)
	{
	load (first,last,hrs,rate,ftax,stax);
	calc(gross,fowed,sowed,net,tgross=0,tfowed=0,tsowed=0,tnet=0,hrs,rate,stax,ftax);
	print(first,last,gross,fowed,sowed,net);
	}
	cout<<"Total Gross"<<setw(10)<<"Total Federal Tax Owed"<<setw(10)<<"Total State Tax Owed"<<setw(10)<<"Total Net Pay"<<endl;
	cout<<tgross<<setw(10)<<"$"<<tfowed<<setw(10)<<"$"<<tsowed<<setw(10)<<"$"<<tnet<<endl;
	system("PAUSE");
	return 0;
}