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

Need help on following program using C++ language. The cost to become a member o

ID: 3686938 • Letter: N

Question

Need help on following program using C++ language.

The cost to become a member of a fitness center is as follows: (a) the senior citizens discount is 30%; (b) if the membership is bought and paid for 12 or more months, the discount is 15%; and (c) 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.

Write your source which should be commented as follows:

Analysis at the top of the file including your test data sets and predicted results.

Function analysis, preconditions, and postconditions after each function prototype

Major tasks identified as comments in main function

Comments in functions as needed.

Explanation / Answer

#include<iostream>

using namespace std;

//function prototype
void printMenu();

double discountedPrice(double original, double discountPer);

int main()
{
   // printing menu
   printMenu();
   int choice;
   double base_price;
   cin>>choice;
   if(choice == 1){
       cout<<"You get 30%% discount"<<endl;
       cout<<"Enter total amount to get membership: ";
       cin>>base_price;
       cout<<"Amount after discount: "<<discountedPrice(base_price, 30)<<endl;
   }
   else if(choice == 2){
       cout<<"You get 15%% discount"<<endl;
       cout<<"Enter total amount to get membership : ";  
       cin>>base_price;
       cout<<"Amount after discount: "<<discountedPrice(base_price, 15)<<endl;
   }
   else if(choice == 3){
       cout<<"You get 20%% discount on each session"<<endl;
       int session =5;
       cout<<"Enter number of session (minimum 5): ";
       cin>>session;
       cout<<"Enter total amount to get membership for one session : ";  
       cin>>base_price;
       cout<<"Amount after discount for all session: "<<session*discountedPrice(base_price, 20)<<endl;
   }
   else{
       cout<<"Invalid options"<<endl;
       }
   return 0;
}

// function definations

// this function print three type of menu
void printMenu(){
   cout<<"Choose which scheme you want to take: "<<endl;
   cout<<"1. You are senior citizens ?"<<endl;
   cout<<"2. You want to be members for 12 or more months ?"<<endl;
   cout<<"3. You want to take more than 5 personal training sessions ?"<<endl;
}

// this function will take amount and discount %, return discounted amount
double discountedPrice(double original, double discountPer){
   return original - (original*discountPer)/100;
}

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