Sample Program to Calculate Weekly Pay with Taxes

//  Emmi Schatz
//  Class Example
//
//  This program reads the hours worked during a week and the hourly pay rate.
//  It calculates the gross pay, deductions (25% of gross), and net pay

#include <iostream.h>

int main()
{
	float hoursWorked;
	float hourlyPay;
	float grossPay;
	float deduction;
	float netPay;

//  read the input values

	cout << "Enter the number of hours worked: ";
	cin >> hoursWorked;
	cout << "Enter the hourly pay rate: ";
	cin >> hourlyPay;

//  calculate the gross pay, deductions, and net pay

	grossPay = hourlyPay * hoursWorked;
	deduction = grossPay * 0.25;
	netPay = grossPay - deduction;

// print gross pay, deductions, and net pay

	cout << "Gross pay   : $" << grossPay << endl;
	cout << "Deduction   : $" << deduction << endl;
	cout << "Net pay   : $" << netPay << endl;
}

Sample Execution:

Enter the number of hours worked: 18
Enter the hourly pay rate: 16.25
Gross pay   : $292.5
Deduction   : $73.125
Net pay   : $219.375

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002