Advertisement
AerosDragonewt

Assignment

Dec 9th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. double operate (double yearlySalary)
  7.     {
  8.         return yearlySalary/52;
  9.     }
  10.  
  11. void salaried()
  12. {
  13.     double yearlySalary;
  14.     cout << "Please enter your yearly salary." << endl;
  15.     cin >> yearlySalary;
  16.     double weeklySalary = operate(yearlySalary);
  17.     float grossPayOne;
  18.     float grossPayTwo;
  19.     cout << "Your weekly stipend is: $" << weeklySalary << endl;
  20.     if (weeklySalary > 3000)
  21.         {
  22.             double taxRate = 0.075;
  23.             cout << "The tax rate for your weekly paycheck is 0.075%." << endl;
  24.             grossPayOne = weeklySalary * taxRate;
  25.             cout << "Your Take Home Stipend is: $" << grossPayOne << endl;
  26.         }
  27.     else if (weeklySalary < 3000)
  28.         {
  29.             double userTaxRate;
  30.             cout << "Please enter your tax rate." << endl;
  31.             cin >> userTaxRate;
  32.             grossPayTwo = weeklySalary * userTaxRate;
  33.             cout << "Your Take Home Stipend is: $" << grossPayTwo << endl;
  34.         }
  35. }
  36.  
  37. double operatorTwo (double hourlyRate, double numOfHours)
  38.     {
  39.         return hourlyRate * numOfHours;
  40.     }
  41.  
  42. double operatorThree (double hourlyRate, double numOfHours)
  43.     {
  44.         return hourlyRate * 40 + 1.5 * hourlyRate * (numOfHours - 40);
  45.     }
  46.  
  47. void hourly()
  48. {
  49.     int taxChoice = 0;
  50.     double hourlyRate;
  51.     double numOfHours;
  52.     double hourWeekSalaryOne = operatorTwo(hourlyRate, numOfHours);
  53.     double hourWeekSalaryTwo = operatorThree(hourlyRate, numOfHours);
  54.     cout << "Please enter your hourly rate & number of hours." << endl;
  55.     cin >> hourlyRate >> numOfHours;
  56.     if (numOfHours < 40)
  57.     {
  58.         float HomePayOne;
  59.         cout << "Your weekly stipend is: $" << hourWeekSalaryOne << endl;
  60.         cout << "Would you like to use the standard 0.075% tax rate or your own? (Enter 0 for standard or 1 for your own)" << endl;
  61.         cin >> taxChoice;
  62.         if (taxChoice == 0)
  63.         {
  64.             HomePayOne = hourWeekSalaryOne * 0.075;
  65.             cout << "Your Take Home Stipend is: $" << HomePayOne << endl;
  66.         }
  67.         else if (taxChoice == 1)
  68.         {
  69.             double UserTaxRateOne;
  70.             cout << "Please enter your tax rate." << endl;
  71.             cin >> UserTaxRateOne;
  72.             HomePayOne = hourWeekSalaryOne * UserTaxRateOne;
  73.             cout << "Your Take Home Stipend is: $" << HomePayOne << endl;
  74.         }
  75.     }
  76.     else if (numOfHours > 40)
  77.     {
  78.         double UserTaxRateTwo;
  79.         float HomePayTwo;
  80.         cout << "Your weekly stipend is: $" << hourWeekSalaryTwo << endl;
  81.         cout << "Would you like to use the standard 0.075% tax rate or your own? (Enter 0 for standard or 1 for your own)" << endl;
  82.         cin >> taxChoice;
  83.         if (taxChoice == 0)
  84.         {
  85.             HomePayTwo = hourWeekSalaryTwo * 0.075;
  86.             cout << "Your Take Home Stipend is: $" << HomePayTwo << endl;
  87.         }
  88.         else if (taxChoice == 1)
  89.         {
  90.             cout << "Please enter your tax rate." << endl;
  91.             cin >> UserTaxRateTwo;
  92.             HomePayTwo = hourWeekSalaryTwo * UserTaxRateTwo;
  93.             cout << "Your Take Home Stipend is: $" << HomePayTwo << endl;
  94.         }
  95.     }
  96. }
  97.  
  98. double operatorFour (double a, double b){
  99.         return (a * b);
  100. }
  101.  
  102. void contracted()
  103. {
  104.     double contractAmount;
  105.     cout << "Please enter amount stated in your contract." << endl;
  106.     cin >> contractAmount;
  107.     double numOfWeeks = 52;
  108.     double contractSalary = operatorFour(contractAmount, numOfWeeks);
  109.     cout << "Your weekly stipend is: $" << contractSalary << endl;
  110.     if (contractSalary > 3000)
  111.         {
  112.             double TaxRate = 0.075;
  113.             float TakeHomePayOne;
  114.             TakeHomePayOne = contractSalary * TaxRate;
  115.             cout << "Your Take Home Stipend is: $" << TakeHomePayOne << endl;
  116.         }
  117.     else if (contractSalary < 3000)
  118.         {
  119.             double InputTaxRate;
  120.             float TakeHomePayTwo;
  121.             cout << "Please enter your tax rate." << endl;
  122.             cin >> InputTaxRate;
  123.             TakeHomePayTwo = contractSalary * InputTaxRate;
  124.             cout << "Your Take Home Stipend is: $" << TakeHomePayTwo << endl;
  125.         }
  126. }
  127.  
  128. int main()
  129. {
  130.     cout << fixed << setprecision(2);
  131.     char employee = 'S' && 'H' && 'C';
  132.     do{
  133.             char employee = 'S' && 'H' && 'C';
  134.     cout << "Welcome to Whirlpool Industries Employee Stipend Calculation System." << endl; // Start of program, welcomes user.
  135.     cout << "This program will produce a calculation of your weekly net pay." << endl;
  136.     cout << "Whirlpool Inc. Employees are categorized into the following categories: Salaried, Hourly, and Contracted." << endl;
  137.     cout << "Please enter what type of employee you are. (Use S, H, or C)[Enter 0 to quit.]" << endl;
  138.     cin >> employee;
  139.     if(employee == '0')
  140.         {
  141.             return 0;
  142.     }
  143.     if(employee != 'S' && employee != 'H' && employee != 'C') cout << "Invalid input, please try again." << endl;
  144.     }while(employee == 'S' || employee == 'H' || employee == 'C');
  145.     if (employee == 'S')
  146.         {
  147.             salaried();
  148.     }
  149.     if (employee == 'H')
  150.         {
  151.             hourly();
  152.     }
  153.     if (employee == 'C')
  154.         {
  155.             contracted();
  156.     }
  157.     return 0;
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement