Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago