Sample Program to Calculate Weekly Pay

//  Emmi Schatz
//  Class Example
//
//  This program reads the hours worked during a week and the hourly pay rate
//  and calculates the weekly pay

#include <iostream.h>

int main()
{
	float hoursWorked;
	float hourlyPay;
	float weeklyPay;

//  read the input values

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

//  calculate and print the weekly pay

	weeklyPay = hourlyPay * hoursWorked;
	cout << "Weekly pay   : $" << weeklyPay;
}

Sample Execution:

Enter the number of hours worked: 18
Enter the hourly pay rate: 12.25
Weekly pay   : $220.5

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

© Copyright Emmi Schatz 2002