Answer to Question #328950 in C++ for farzii

Question #328950

// I need this answer this proper explonation + full step by step please if any one know //


Q1: (Salary Calculator) Develop a C++ program that uses a while statement to determine the gross pay for each of several employees. The company pays “straight time” for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked in excess of 40 hours. You are givenalist of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee and should determine and display the employee’s gross pay.

Enter hours worked (-1 to end): 39

Enter hourly rate of the employee ($00.00): 10.00

Salary is $390.00 Enter hours worked (-1 to end): 40

Enter hourly rate of the employee ($00.00): 10.00

Salary is $400.00

<..............................................................................>


1
Expert's answer
2022-04-15T04:43:38-0400
#include <iostream>

using namespace std;

int main()
{
	int hours;//hours worked by each employee
	float hRate; //hourly rate of the employee
	double salary;
	do
	{
		cout << "Enter hours worked (-1 to end): ";
		cin >> hours;
		if (hours <= -1)break;//Exit program if -1
		cout << "Enter hourly rate of the employee ($00.00): ";
		cin >> hRate;//
		if (hours > 40)
			salary = (float)(40* hRate+(hours-40)*1.5*hRate);
		else
			salary = (float)hours*hRate;
		cout << "Salary is $" << salary << endl;
	} while (true);
	
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS