Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

User - Defined Functions The cost to become a member of a fitness center is as follows: The senior citizens discount is 30% If the

User - Defined Functions 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.)

Please use this code, I'm trying to figure out where and what to input to solve the problem. What am I missing?

#include #include #include using namespace std;

void displayInfo(); int readData(); int memCost(int, int, int); //the main function int main () { int cost; displayInfo(); cost = readData(); cout << "The cost of the membership is :$" << cost << endl; system ("PAUSE"); return 0; } //the display function void displayInfo() { cout<<" \tFitness Center - General Information " << endl; cout<<"Membership for month: $20 "; cout<<"Personal training sessions: $15 "; cout<<"Discount for Senior citizens: 30% "; cout<<"Discount for purchasing 12 or more months 15% "; cout<<"Discount for purchasing 5 or more personal training sessions 20% "; } //the read data function int readData () { int srCitizen, proChoice, months, sessions, cost; cout<<"Enter your purchase details... "; cout<<"Enter 1 if you are a senior citizen or 0 if not : "; cin>>srCitizen; if(srCitizen != 1) { srCitizen =0; cout<<" Choose your fitness program... "; cout<<"1. Monthly membership "; cout<<"2. Personal Training "; cout<<" Enter your choice : "; } do { cin>>proChoice; if (proChoice<1 || prochoice>2) cout<<"Enter a valid choice :"; } while(proChoice<1 || prochoice>2);

if(proChoice==1) { cout<<"Enter number of months you want : "; cin>>months; } if(proChoice==2) { cout<<"Enter number of sessions you want : "; cin>>sessions; cost = memCost(srCitizen, months, sessions); } return cost; } //the memCost function int memCost(int srCitizen, int months, int sessions) { int cost; if(sessions<=5) { cost = sessions*20; } else { cost = sessions - (sessions * 0.20); } if(months<=12) { cost = months * 20; } else { cost = months * (months * 0.15); } if(srCitizen==1) { cost = cost - (cost * 0.30); } return cost; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

1. Define mass and mediated communication

Answered: 1 week ago