Advertisement
riggnaros

fitness membership calc

Oct 23rd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <limits>
  4. #include <cmath>
  5. #include <iomanip>
  6.  
  7. void displayMenu();
  8. void getInput(int& age, int& months, int& ptChoice);
  9. void calculateMembership(int& age, int& months, int& ptChoice, double& membership, double& PTtotal);
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.     // Write your main here
  15.  
  16.     int age = 0;
  17.     int ptChoice = 0;
  18.     int months = 0;
  19.     double PTtotal = 10.00;
  20.     double membership = 20.00;
  21.  
  22.     displayMenu();
  23.     getInput(age, months, ptChoice);
  24.     calculateMembership(age, months, ptChoice, membership, PTtotal);
  25.  
  26.     return 0;
  27. }
  28.  
  29. void displayMenu()
  30. {
  31.     cout << "\n                           ****Fitness Menu****                           " << endl;
  32.     cout << "          ********************************************************          " << endl;
  33.     cout << "                  Basic Membership Price:$20.00 per month.                  " << endl;
  34.     cout << "                  Senior Discount:                     30% off              " << endl;
  35.     cout << "                  12 month special:                    15% off              " << endl;
  36.     cout << "                  Sign up for more than 5 PT sessions  20% off              " << endl;
  37. };
  38.  
  39. void getInput(int& age, int& months, int& ptChoice)
  40. {
  41.     cout << "\nPlease answer the following information to calculate your monthly membership costs.";
  42.     cout << endl
  43.          << "Please enter your age: ";
  44.     cin >> age;
  45.     cout << "How many months do you wish to purchase a membership? ";
  46.     cin >> months;
  47.     cout << "How many personal training sessions have you paid for?: ";
  48.     cin >> ptChoice;
  49. };
  50.  
  51. void calculateMembership(int& age, int& months, int& ptChoice, double& membership, double& PTtotal)
  52. {
  53.     double overallTotal;
  54.     double overallPTtotal;
  55.     double grandTotal;
  56.  
  57.     if (age < 18) {
  58.         cout << "***You must be at least 18yrs of age or older.***";
  59.     }
  60.  
  61.     if (age >= 65 && months >= 12) {
  62.         membership = membership - (membership * .45);
  63.     }
  64.     if (age >= 65 && months < 12) {
  65.         membership = membership - (membership * .30);
  66.     }
  67.     if (age < 65 && age >= 18 && months >= 12) {
  68.         membership = membership - (membership * .15);
  69.     }
  70.     if (age < 65 && age >= 18 && months < 12) {
  71.         membership = 20.00;
  72.     }
  73.  
  74.     if (ptChoice > 5) {
  75.         PTtotal = PTtotal - (PTtotal * .20);
  76.     }
  77.     if (ptChoice < 5) {
  78.         PTtotal = 10.00;
  79.     }
  80.  
  81.     overallTotal = membership * months;
  82.     overallPTtotal = ptChoice * PTtotal;
  83.     grandTotal = overallTotal + overallPTtotal;
  84.  
  85.     cout << "\nThis is your monthly Membership rate: $" << setprecision(2) << fixed << membership;
  86.     cout << "\nThis is your total Membership cost: $" << setprecision(2) << fixed << overallTotal;
  87.     cout << endl
  88.          << "\nThis is your Personal Training cost per session: $" << setprecision(2) << fixed << PTtotal;
  89.     cout << "\nThis is your total Personal Training cost: $" << setprecision(2) << fixed << overallPTtotal;
  90.     cout << endl
  91.          << "\nThis is your Grand Total: $" << setprecision(2) << fixed << grandTotal;
  92. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement