Answer to Question #319842 in C++ for rem

Question #319842

Create a program that will compute the salary of an employee. Salary is computed as hours worked times rate per hour. Rate is based on the inputted employee code. Consider the following:

Employee Code Rate per hour

1 100.00

2 200.00

3 350.00

4 500.00



1
Expert's answer
2022-03-28T17:44:14-0400
#include <iostream>
using namespace std;

int main()
{
	std::cout.setf(std::ios::fixed);
	std::cout.precision(2);
	
	double rate1 = 100.00;
	double rate2 = 200.00;
	double rate3 = 350.00;
	double rate4 = 500.00;
	double salary;
	cout << "Enter code: ";
	int i;
	cin >> i;
	cout << "Enter number of hours worked: ";
	int hours;
	cin >> hours;
	switch (i)
	{
	case 1:
		salary = hours * rate1;
	case 2:
		salary = hours * rate2;
	case 3:
		salary = hours * rate3;
	case 4:
		salary = hours * rate4;
	default:
		break;
	}
	cout << "Salary: " << salary;
}

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