Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ The cost to become a member of a fitness center is as follows: The senior ci

ID: 3819839 • Letter: C

Question

C++

The cost to become a member of a fitness center is as follows:

The senior citizens discount is 30%

If the membership is bought and paid for 12 or more months, the discount is 15%

If more than five personal training sessions are bought and paid for, the discount on each session is 20%.

Write a menu-driven program that determines the cost of a new membership. Your program must contain a function that displays the general information about the fitness center and its charges, a function to get all of the necessary information to determine the membership cost, and a function to determine the membership cost. Use appropriate parameters to pass information in and out of a function. (Do not use any global variables.)

Following Test Parameters need to be satisfied:

Test Case

FAILED:

12 month discount

Input

Output

Results

$12240.00

Expected Output

$12240.00

----

FAILED:

Senior citizen discount

Input

Output

Results

$2260.00

Expected Output

$2260.00

-----

FAILED:

Non senior citizen

Input

Output

Results

$6400.00

Expected Output

$6400.00

Explanation / Answer

#include<iostream>
using namespace std;

int main()
{
   //function to show menu and get choice from user
   void menu();
   int n, m;
   int choice;
   float amt, discount=0;
   do
   {
       menu();
       cout << "Enter your choice: ";
       cin >> choice;
       switch (choice)
       {
       case 1:
           discount = 0;
           cout << "Enter the amt = ";
           cin >> amt;
           discount = amt * 30 / 100;
           amt -= discount;
           cout << "Senior citizen discount = $" << discount<<" and amount to be paid after discount = $"<<amt << endl;
           break;
       case 2:
           discount = 0;
           cout << "Enter the number of months: ";
           cin >> m;
           cout << "Enter the amont per month = ";
           cin >> amt;
           amt = amt * m;
           if (m >= 12)
           {
               discount += amt * 15 / 100;
           }
           amt -=discount;
           cout << "12 months or more discount = $" << discount<<" and amount to be paid after discount = $"<<amt << endl;
           break;
       case 3:
           int tmp ;
           discount = 0;
           cout << "Enter amount per session: ";
           cin >> amt;
           cout << "Enter number of session = ";
           cin >> n;
           tmp = n;
           //if 5 or more sessions discount 20% on each sessain
           while (n--)
           {
               discount += amt * 20 / 100;
           }
           n = tmp;
           amt = amt * n - discount;
           cout << "Discount for more than 5 years = $" << discount<<" and amount to be paid after discount= $"<<amt << endl;
           break;
       case 4:
       default:
           cout << "Quit application" << endl;
           break;
       }
      
   } while (choice != 4);
}

void menu()
{
   cout << "Choose from following membership option" << endl;
   cout << "1.Senior citizen discount 2.Membership baught and paid for 12 or more months 3.More than 5 training sessions baught 4.Quit" << endl;

}

---------------------------------------------------------------------------------------------

//output

1.Senior citizen discount
2.Membership baught and paid for 12 or more months
3.More than 5 training sessions baught
4.Quit
Enter your choice: 2
Enter the number of months: 12
Enter the amont per month = 110
12 months or more discount = $198 and amount to be paid after discount = $1122
Choose from following membership option
1.Senior citizen discount
2.Membership baught and paid for 12 or more months
3.More than 5 training sessions baught
4.Quit
Enter your choice: 3
Enter amount per session: 6
Enter number of session = 10
Discount for more than 5 years = $12 and amount to be paid after discount= $48
Choose from following membership option
1.Senior citizen discount
2.Membership baught and paid for 12 or more months
3.More than 5 training sessions baught
4.Quit
Enter your choice: 4
Quit application

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote