Dabeen Park/C /Enter paycode

From Biolecture.org
Revision as of 13:18, 14 December 2017 by imported>DabeenPark (Created page with "<p>#include <iostream><br /> #include <iomanip><br /> using namespace std;<br /> int main()<br /> {<br /> int num;<br /> double sal;<br /> int h;<br /> int g;<br /> w...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

#include <iostream>

  1. include <iomanip>

using namespace std;
int main()
{
int num;
double sal;
int h;
int g;
while(1)
{
cout << "Enter paycode (-1 to end): ";
cin >> num;
cout << fixed << showpoint << setprecision(2);
if(num==-1)
{
break;
}
switch(num)
{
case 1 : cout << "Manager selected." << endl;
cout << "Enter weekly salary: ";
cin >> sal;
cout << "The manager's pay is " << sal << " won" << endl;
cout << endl;
break;
case 2 : cout << "Hourly worker selected." << endl;
cout << "Enter the hourly salary: ";
cin >> sal;
cout << "Enter the total hours worked: ";
cin >> h;
if(h<40)
{
cout << "Worker's pay is " << sal * h << " won" << endl;
cout << endl;
}
else if(h>40)
{
double t = 0;
t = (h - 40);
t = t * 1.5;
t = t * sal;
cout << "Worker's pay is " << (sal * 40) + t << " won" << endl;
cout << endl;
}
break;
case 3 : cout << "Commission worker selected." << endl;
cout << "Enter gross weekly sales: ";
cin >> g;
cout << "Commission worker's pay is " << (300000 + ((0.057) * g)) << " won" << endl;
cout << endl;
break;
default : cout << "invalid pay code." << endl;
cout << endl;
break;
}
}
return 0;
}