Advertisement
AerosDragonewt

New Version

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