Question: In C++, Write a program that asks the number of hours worked and hourly pay rate as floating point numbers. Then, it displays the calculated

In C++,

Write a program that asks the number of hours worked and hourly pay rate as floating point numbers. Then, it displays the calculated total pay. Hours worked over 40 hours are considered as overtime and should be calculated at 1.5 times the pay rate.

Be sure to have input validation. If one or both input values are negative values, it does not make sense. If a pay rate of -$10 and 41 hours worked, then the pay would be -$415. Instead of printing the negative value of the pay, print "Invalid input".

For example, if Punith worked 42 hours (40 hours + 2 hours of overtime), and his pay rate is $12. Then, his paycheck will be $516.

Regular Pay: $ 480.00 ($12 x 40 hours) Overtime Pay: $ 36.00 (1.5 x $12 * 2 hours) Total Pay: $ 516.00

The total pay(pay check) should be formatted with a two-digit precision.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!