View Single Post
Old 12-06-2004, 01:37 PM   #3 (permalink)
verdell32
Registered User
 
verdell32's Avatar
 
Join Date: Oct 2004
Posts: 35
verdell32 is on a distinguished road
paycheck no has to be overtime

it was called pacheck.cpp, but I think this time we have to add the if and else statments in the code.

// Program Documentation //////////////////////////////////////////////////////
//
// Project Name : PAYCHECK
//
// Source File : paycheck.cpp
//
// Programmed By :
//
// Last Revision : 10/12/2004
//
// Version Number: 0.1
//
// Program Description ////////////////////////////////////////////////////////
//
// This program calculates employees pay rate, hours worked, gross pay, net pay
// federal tax, state tax and will output to screen.
///////////////////////////////////////////////////////////////////////////////

// Include Files //////////////////////////////////////////////////////////////
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

// Function Prototypes ////////////////////////////////////////////////////////

// Program Mainline ///////////////////////////////////////////////////////////

int main( )
{
const double FEDERAL_TAX_RATE = .33;
const double STATE_TAX_RATE = 0.06;

char employeeName[64];
double federalTax;
double grossPay;
double hoursWorked;
double netPay;
double payRate; //stores employee's pay rate as a real number
double stateTax;

//input data
cout << "Enter employee name:";
cin.getline( employeeName, sizeof( employeeName ));
cout << "Enter pay rate:";
cin >> payRate;
cout << "Enter hours worked:";
cin >> hoursWorked;

//calculations
grossPay = hoursWorked * payRate;
federalTax = grossPay * FEDERAL_TAX_RATE;
stateTax = grossPay * STATE_TAX_RATE;
netPay = grossPay - federalTax + stateTax;


//output results
cout.setf(ios::fixed,ios::floatfield);
cout.precision( 2 ); //output 2 decimal places
const int fw = 10;

cout << "================================================= ==============================" << endl;
cout << "Employee Hours Federal State" << endl;
cout << "Name Worked Pay Rate Gross Pay Net Pay Tax Tax" << endl;
cout.setf(ios::left,ios::adjustfield);
cout << setw(fw + 9) << employeeName;
cout.setf(ios::right,ios::adjustfield);
cout << setw(fw)<< hoursWorked;
cout << setw(fw)<< payRate;
cout << setw(fw)<< grossPay;
cout << setw(fw)<< netPay;
cout << setw(fw)<< federalTax;
cout << setw(fw)<< stateTax;
cout << "" << endl;

cout << "================================================= ===============================" << endl;

getch();
return 0;
}//endmn
verdell32 is offline   Reply With Quote