112k views
3 votes
What will be the value of pay after the following statements are executed?

int hours 45;
double pay, payRate 10.00;
pay hours <= 40 ? hours * payRate : 40) payRate 1.5; 40 * payRate + (hours
-40) * payrate * 1.5;
a) 450.00
b) 400.00
c) 475.00
d) 465.00

1 Answer

7 votes

Final answer:

After executing the provided conditional expression with an hours value of 45 and a payRate of $10.00, the total pay will be $475.00. It includes pay for the first 40 hours and increased pay for 5 hours of overtime.

Step-by-step explanation:

The student has provided a conditional expression to calculate the pay based on the number of hours worked and a payRate. The condition checks if the hours are less than or equal to 40. If true, it calculates the pay using just the payRate times the hours. If false, it pays for the first 40 hours at the normal payRate, then any additional hours at 1.5 times the payRate.

To find the value of pay after executing the statements:

  • Hours worked: 45
  • payRate: $10.00
  • First 40 hours: 40 hours × $10.00 = $400.00
  • Overtime (5 hours): 5 hours × $10.00 × 1.5 = $75.00
  • Total pay: $400.00 + $75.00 = $475.00

User Ruslan Leshchenko
by
8.2k points