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
#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;
}
Comments
Leave a comment