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

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

ID: 3820731 • Letter: T

Question

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 in C++ 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.)

Explanation / Answer

C++ Code:

#include <iostream>
#include <iomanip>
using namespace std;


void display();
double ask(double& price);

int main()
{
double price;
display();
ask(price);
cout << "Price will be: " << price << endl;
return 0;

}

void display()
{


cout << " Fitness Menu "<< endl;;
cout << "_______________________________________"<< endl;
cout << "Price for joining is $30.00 " << endl;
cout << "Senior Citizen discount will be 30%" << endl;
cout << "If the membership has paid for 12 months or more, there is 15% discount" << endl;
cout << "If more than 5 personal training sessions are paid for, there is 20% discount" << endl;
cout << "_______________________________________"<< endl;

return ;

}

double ask(double& price)
{

char senior;
char twelveormore;
char training;

// asks questions from the user

price = 30.00;

cout << "Are you a senior citizen? " << endl;
cin >> senior;
if((senior == 'Y')||(senior == 'y')){
// even if the user hits something other than Y or y it still changes variable
cout <<"Senior discount applied "<<(price*.3)<<" Removed from cost" <<endl;
price=price-(price*.3);}

cout << "Have you paid for more than 12 months?" << endl;
cin >> twelveormore;
if((twelveormore == 'Y')||(twelveormore == 'y')){
cout <<"12 month discount applied "<<(price*.15)<<" Removed from cost" <<endl;
price=price-(price*.15);}

cout << "Have you received more than 5 personal training sessions? " << endl;
cin >> training;
if((training == 'Y')||(training == 'y')){
cout <<"Trainer discount applied "<<(price*.2)<<" Removed from cost" <<endl;
price=price-(price*.2);}

return price;
}

Stdin :

Y

Y

stdout :

Fitness Menu
_______________________________________
Price for joining is $30.00
Senior Citizen discount will be 30%
If the membership has paid for 12 months or more, there is 15% discount
If more than 5 personal training sessions are paid for, there is 20% discount
_______________________________________
Are you a senior citizen?
Senior discount applied 9 Removed from cost
Have you paid for more than 12 months?
12 month discount applied 3.15 Removed from cost
Have you received more than 5 personal training sessions?
Price will be: 17.85

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