Problem Statement
In some locations, hourly-paid employees are given a premium for working "overtime" hours, which are those hours worked after the first 40 in a given week. Those hours make a rate of pay equal to 1.5 times the normal hourly rate of pay.
You are given hoursWorked, the number of hours worked that week, and hourlyRate, the normal rate of pay per hour. Calculate the total pay, taking into account any overtime hours.
Definition
- Class:
- WorkingOvertime
- Method:
- totalPay
- Parameters:
- double, double
- Returns:
- double
- Method signature:
- double totalPay(double hoursWorked, double hourlyRate)
- (be sure your method is public)
Constraints
- hoursWorked will be between 0 and 100, inclusive.
- hourlyRate will be between 0 and 100, inclusive.
Examples
40
10
Returns: 400.0
Working exactly 40 hours means there's no overtime bonus, so it's just a simple 40 * 10.100
0
Returns: 0.0
Someone worked a lot of hours at an unpaid internship.50
16
Returns: 880.0
The first 40 hours are paid regularly, so 40 * 16 = 640. The remaining 10 hours are paid a 1.5x rate, so 10 * 16 * 1.5 = 240, for a total of 880.30
12
Returns: 360.0