Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <limits>
- #include <cmath>
- #include <iomanip>
- void displayMenu();
- void getInput(int& age, int& months, int& ptChoice);
- void calculateMembership(int& age, int& months, int& ptChoice, double& membership, double& PTtotal);
- using namespace std;
- int main()
- {
- // Write your main here
- int age = 0;
- int ptChoice = 0;
- int months = 0;
- double PTtotal = 10.00;
- double membership = 20.00;
- displayMenu();
- getInput(age, months, ptChoice);
- calculateMembership(age, months, ptChoice, membership, PTtotal);
- return 0;
- }
- void displayMenu()
- {
- cout << "\n ****Fitness Menu**** " << endl;
- cout << " ******************************************************** " << endl;
- cout << " Basic Membership Price:$20.00 per month. " << endl;
- cout << " Senior Discount: 30% off " << endl;
- cout << " 12 month special: 15% off " << endl;
- cout << " Sign up for more than 5 PT sessions 20% off " << endl;
- };
- void getInput(int& age, int& months, int& ptChoice)
- {
- cout << "\nPlease answer the following information to calculate your monthly membership costs.";
- cout << endl
- << "Please enter your age: ";
- cin >> age;
- cout << "How many months do you wish to purchase a membership? ";
- cin >> months;
- cout << "How many personal training sessions have you paid for?: ";
- cin >> ptChoice;
- };
- void calculateMembership(int& age, int& months, int& ptChoice, double& membership, double& PTtotal)
- {
- double overallTotal;
- double overallPTtotal;
- double grandTotal;
- if (age < 18) {
- cout << "***You must be at least 18yrs of age or older.***";
- }
- if (age >= 65 && months >= 12) {
- membership = membership - (membership * .45);
- }
- if (age >= 65 && months < 12) {
- membership = membership - (membership * .30);
- }
- if (age < 65 && age >= 18 && months >= 12) {
- membership = membership - (membership * .15);
- }
- if (age < 65 && age >= 18 && months < 12) {
- membership = 20.00;
- }
- if (ptChoice > 5) {
- PTtotal = PTtotal - (PTtotal * .20);
- }
- if (ptChoice < 5) {
- PTtotal = 10.00;
- }
- overallTotal = membership * months;
- overallPTtotal = ptChoice * PTtotal;
- grandTotal = overallTotal + overallPTtotal;
- cout << "\nThis is your monthly Membership rate: $" << setprecision(2) << fixed << membership;
- cout << "\nThis is your total Membership cost: $" << setprecision(2) << fixed << overallTotal;
- cout << endl
- << "\nThis is your Personal Training cost per session: $" << setprecision(2) << fixed << PTtotal;
- cout << "\nThis is your total Personal Training cost: $" << setprecision(2) << fixed << overallPTtotal;
- cout << endl
- << "\nThis is your Grand Total: $" << setprecision(2) << fixed << grandTotal;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement