Thursday, July 26, 2012

CPro 1 Assignment: If Statement

CPro 1 Assignment: If Statement

Problem:
Foo Corporation needs a program to calculate how much to pay their hourly employees. The US Department of Labor requires that employees get paid time and a half for any hours over 40 that they work in a single week. For example, if an employee works 45 hours, they get 5 hours of overtime, at 1.5 times their base pay. The State of Massachusetts requires that hourly employees be paid at least $8.00 an hour. Foo Corp requires that an employee not work more than 60 hours in a week.

Specification:
An employee gets paid (hours worked) × (base pay), for each hour up to 40 hours. For every hour over 40, they get overtime = (base pay) × 1.5. The base pay must not be less than the minimum wage ($8.00 an hour). If it is, print an error. If the number of hours is greater than 60, print an error message.

Directions:
Use if statement to implement the specification;
Use scanf function to get user input(ie base pay and hours worked);
Write your code on a short bond paper;

Output:
Enter base pay: 8.2
Enter hours worked: 47

Total pay is  423.32

No comments:

Post a Comment