Advertisement
AerosDragonewt

Old Version

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