Answer:
#include <iostream>
using namespace std;
void information(){
cout<<"Welcome to the portal"<<endl;
cout<<"The membership fee per month is $50.00"<<endl;
cout<<"The personal training session fee is $30.00"<<endl;
cout<<"The senior citizens discount is 30%"<<endl;
cout<<"If the membership is bought and paid for 12 or more months, the discount is 15%;"<<endl;
cout<<"If more than five personal training sessions are bought and paid for, the discount on each session is 20%."<<endl;
}
void getInfo(bool &senior, int &months, int &personal){
cout<<"Are you senior citizen y/n ? : ";
char choice;
cin>>choice;
if(choice=='y' || choice=='Y'){
senior = true;
}else{
senior = false;
}
cout<<"Enter number of months for membership : ";
cin>>months;
cout<<"Enter number of personal training session : ";
cin>>personal;
}
double calcCost(bool senior, int months, int personal){
double cost=0;
double memberShipCost=months*50;
double trainingCost=personal*30;
if(personal>5){
trainingCost*=.80; //discount on personal training
}
if(months>=12){
memberShipCost*=.85; //discount on membership
}
cost = memberShipCost+trainingCost;
//discount for seniors
if(senior){
cost = cost*.70;
}
return cost;
}
int main() {
information();
cout<<"Select an option"<<endl;
char choice;
while(true){
cout<<endl<<endl;
cout<<"a. Calculate membership costs."<<endl;
cout<<"b. Quit program."<<endl;
cout<<"Enter your choice : ";
cin>>choice;
bool senior=true;
int months,personal;
if(choice=='a'){
getInfo(senior,months,personal);
double cost=calcCost(senior, months, personal);
cout<<"The calculated cost is $"<<cost<<endl;
}else if(choice=='b'){
break;
}
}
return 0;
}
Step-by-step explanation: