CST8110 Lab Exercise 5 – if statement


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (4 votes)

Write a program (method main) to solve the following problem: A company
needs to calculate an employee’s wages.
• Prompt the user for the number of hours worked by the employee this week,
and the hourly rate they get paid.
• The company pays straight time as base pay for the first 37.5 hours worked
(ie hours multiplied by rate) and time and a half for the hours worked
over 37.5 (ie hours multiplied by rate*1.5). Calculate base pay and
overtime pay.
• Income tax is deducted and is calculated as 0 for wages (base pay plus
overtime) less than $1,000 for the week, 20% for wages between $1,000 and
$2,000 inclusive, and 30% otherwise. Calculate income tax.
• Display base pay, overtime pay, tax deducted and net pay for the employee.
BONUS: add editing so that only hours of 0-60 can be entered, and rate of
pay can only be 0-1500. (Don’t need to add handling for alphabetic entry
Example 1:
Enter the number of hours worked : 40
Enter the rate of pay: 10.00
Base pay is $ 375.00
Overtime pay is $ 37.50
Total pay is $412.50
Tax deducted is $ 0.00
Net pay is $ 412.50
Example 2:
Enter the number of hours worked : 30
Enter the rate of pay: 100.00
Base pay is $ 3000.00
Overtime pay is $ 0.00
Total pay is $ 3000.00
Tax deducted is $ 900.00
Net pay is $ 2100.00