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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
//AcmePayroll.cpp
//Te Mat
// June 29, 2014
//Project 1
//[Uses information entered by user to calculate payroll]
#include <iostream>
#include <iomanip>
using namespace std;
int main()// function main begins program execution
{
int paycode,
TotalHours,
sales;
double pay1,
pay2,
pay3,
pay4,
TotalPay,
HourlyPay,
SalesComm,
WeeklySalary,
WeeklyPay,
PayPerWidget,
WidgetsSold,
GrossWeeklySales;
cout << "Enter pay code ([Q]uit):";
cin >> paycode;
cout << fixed << showpoint << setprecision(2);
switch (paycode)
{
case 1:
cout << "Manager selected." << endl;
cout << "Enter weekly salary: ";
cin >> WeeklySalary;
cout << endl;
pay1 = WeeklySalary;
cout << "Managers pay is $" << pay1;
cout << endl;
break;
case 2:
cout << "Hourly Worker selected." << endl;
cout << "Enter the hourly pay:";
cin >> HourlyPay;
cout << endl;
cout << "Enter the total hours worked:";
cin >> TotalHours;
if (TotalHours <= 40)
pay2 = HourlyPay * TotalHours;
else
pay2 = (40 * HourlyPay) + (TotalHours - 40) * (HourlyPay * 1.5)
cout << endl;
cout << "Hourly Worker's pay is $"; << pay2;
cout << endl;
break;
case 3:
cout << "Commission Worker selected." << endl;
cout << "Enter weekly salary:";
cin >> WeeklyPay;
cout << endl;
cout << "Enter commission (%): ";
cin >> SalesComm;
cout << endl;
cout << "Enter gross weekly sales:";
cin >> GrossWeeklySales;
cout << endl;
pay3 = (SalesComm / 100) * GrossWeeklySales + WeeklyPay;
cout << " Commission Worker's pay is $" << pay3;
cout << endl;
break;
case 4:
cout << "Widget Worker selected." << endl;
cout << "Enter pay per widget:";
cin >> PayPerWidget;
cout << endl;
cout << "Enter number of widgets: ";
cin >> WidgetsSold;
cout << endl;
pay4 = PayPerWidget * WidgetsSold;
cout << "Widget Worker's pay is $" << pay4;
cout << endl;
break;
TotalPay = pay1 + pay2 + pay3 + pay4;
char usersPression = ' ' ;
do
{
cout << " Total pay is $" << TotalPay;
}while(usersPression != 'Q' && usersPression != 'q');
}
return 0;
}
|