Answered Essay: Write a program that displays a message, asks a user to enter the number of hours worked in one week, and the ba

Problem 2: Write a program that displays a message, asks a user to enter the number of hours worked in one week, and the base hourly rate in dollars. The program then computes the weekly gross pay for the user or produces an error message if erroneous data was inputted. An example of an erroneous data is when the user enter strings instead of numbers. It should be noted that (1) the employee is paid 1.5 times the base hourly rate for hours worked above 40 hours but below or equal 60 hours, (2) the employee is paid 2 times the base hourly rate for hours worked above 60 hours Example output: Four Reals Incorporated Weekly Gross Pay Calculator Enter number of hours worked: 45 Enter your base hourly rate: 10.75 Your weekly gross pay is 510.625 dollars

Write a program that displays a message, asks a user to enter the number of hours worked in one week, and the base hourly rate in dollars. The program then computes the weekly gross pay for the user or produces an error message if erroneous data was inputted. An example of an erroneous data is when the user enter strings instead of numbers. It should be noted that (1) the employee is paid 1.5 times the base hourly rate for hours worked above 40 hours but below or equal 60 hours, (2) the employee is paid 2 times the base hourly rate for hours worked above 60 hours Example output: Four Reals Incorporated Weekly Gross Pay Calculator Enter number of hours worked: 45 Enter your base hourly rate: 10.75 Your weekly gross pay is 510.625 dollars

Expert Answer

 

here i have written the C++ program as per the requirement.

—————————————————————————————————————————————-

Note: Please note that the below program has been tested on ubuntu 16.04 system and compiled under gcc compiler. This code will also work on other IDE’s.

——————————————————————————————————————————————

Program:

——————————————————————————————————————————————

//header file declrations

#include<iostream>

#include<cctype>

#include<stdlib.h>

//Namespace declrations

using namespace std;

//start of main function

int main()

{

//variable data type declrations

int w_hours;

float b_rate, w_gross_pay;

//ask for input values

cout<<“———————————-“<<endl;

cout<<“Four Reals Incorporated”<<endl;

cout<<“Weekly Gross Pay Calculator”<<endl;

cout<<“———————————-“<<endl;

cout<<“Enter the number of hours worked: “;

cin>>w_hours;

cout<<“Enter your base hourly rate: “;

cin>>b_rate;

//if both inputs are integers

if(w_hours && b_rate)
{

//if hours are greter then 40 and less than = 60
if(w_hours > 40 && w_hours <= 60)

{

//calculate weekly pay

w_gross_pay = 40 * b_rate + (w_hours – 40) * 1.5 * b_rate;

}

//if hours are greter than 60

else if(w_hours > 60 )

{

//calculate gross pay

w_gross_pay = 40 * b_rate + (w_hours – 40 ) * 1.5 * b_rate;

}

//if hours are less than = 40

else if(w_hours <= 40)

{

//calculate gross pay

w_gross_pay = w_hours * b_rate;

}

}

//if input is not integr vale

else

{

cout<<“erroneous data was entered.”<<endl;

}

//display the weekly pay in dollers

cout<<endl<<“Your weekly gross pay is “<<w_gross_pay<<” dollars.”<<endl;

return 0;

}//end of the main function

—————————————————————————————————————————————

here i have attached a sample run of the program as a screen shot…

————————————————————————————————————————————————–

Output:

—–

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.