How do I make this program continue to ask for a paycode after the previous case is complete? And then also show how many times each case has been used?
Sample Output:
Enter paycode (-1 to end): 3
Commission worker selected.
Enter gross weekly sales: 4000
Commission worker’s pay is $ 478.00
Enter paycode (-1 to end): 2
Hourly worker is selected.
Enter hourly salary: 4.5
Enter the total hours worked: 20
Worker’s pay is $90.00
Enter paycode (-1 to end): -1
Total number of managers paid :0
Total number of hourly workers paid :1
Total number of commission workers paid :1
Total number of piece workers paid :0
I know that there needs to be a loop, but not sure how to use it...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include<iostream>
using namespace std;
int main()
{
float num1, num2, num3, num4, num5, num6, num7;
int option_select;
cout << "Enter paycode: " << endl;
//1 for manager
//2 for hourly workers
//3 for commission workers
//4 for pieceworkers
cout << endl;
cin >> option_select;
switch (option_select);
{
case 1:
cout << "Manager worker is selected" << endl;
cout << "Enter fixed weekly salary" << endl;
cin >> num1;
cout << "Manager's pay is: " << num1 << endl;
break;
case 2:
cout << "Hourly worker is selected" << endl;
cout << "Enter hourly salary: " << endl;
cin >> num2;
cout << "Enter amount of hours worked: " << endl;
cin >> num3;
if (num3 <= 40)
cout << "Hourly workers pay is: " << (num2 *num3) << endl;
else
if ((num3 - 40) >= 1)
cout << "Hourly workers pay plus Overtime Pay: " << ((num3 - 40) * (num2 * 1.5) + (40 * num2)) << endl;
break;
case 3:
cout << "Commision worker is selected" << endl;
cout << "Enter gross weekly sales: " << endl;
cin >> num5;
cout << "Commision worker's pay is: " << 250 + (num5 *.057) << endl;
break;
case 4:
cout << "Piece worker is selected"
cout << "Enter amount paid per item: " << endl;
cin >> num6;
cout << "Enter amount of items produced: " << endl;
cin >> num7;
cout << "Piece Worker's pay is: " << num6 *num7 << endl;
break;
default:
cout << "The entered code is not found " << endl;
} // end of switch
system("pause");
return 0;
} // end of the main
|