Page 1 of 1

#include #include #include using namespace std; // Function prototypes void printGeneralIn

Posted: Thu Jul 14, 2022 2:18 pm
by answerhappygod
#include <iostream>#include <iomanip>#include <string>using namespace std;
// Function prototypesvoid printGeneralInfo();void readData(double& costPerMonth, double&costPerTraining,bool& seniorCitizen, int& numOfSessions, int&number0fMonths);double calcMembershipCost(double costPerMonth, doublecostPerTraining,bool seniorCitizen, int numOfSessions, int numOfMonths);
//Program begins with a main functionint main(){//Declare variablesdouble costPerMonth;double costPerTraining;bool seniorCitizen;int numOfSessions;int numOfMonths;double costMemberShip;char choice;//Read input from the usercout << "\n*Welcome to Fitness Center*" << endl;do{printGeneralInfo();readData(costPerMonth,costPerTraining,seniorCitizen, numOfSessions,numOfMonths);costMemberShip = calcMembershipCost(costPerMonth,costPerTraining,seniorCitizen, numOfSessions, numOfMonths);cout << "\nCost of the new membership: $"<< setprecision(2) << fixed<< costMemberShip << endl;cout << "\nEnter 'Y' for another membership: ";cin >> choice;} while (choice == 'Y' || choice == 'y');return 0;}
//Method definition of printGeneralInfo: It displays thegeneral//information about the fitness center and itschargesvoid printGeneralInfo(){cout << "\nThe discounts at this Fitness Center are:"<< endl;cout << "(a) 30% discount for the senior citizens."<< endl;cout << "(b) 15% discount if the membership is bought"<< endl;cout << " and paid for 12 or more months" <<endl;cout << "(c) 20% discount on each session if more than"<< endl;cout << " five personal training sessions are bought and paidfor."<< endl;}//Method definition of readDatavoid readData(double& costPerMonth,double& costPerTraining,bool& seniorCitizen, int& numOfSessions,int& numOfMonths){cout << "\nEnter the cost per month of a regular membership:$";cin >> costPerMonth;cout << "Enter the cost per a personal training session:$";cin >> costPerTraining;cout << "Enter 'Y' if you are senior citizen: ";char ch;cin >> ch;if (ch == 'Y' || ch == 'y')seniorCitizen = true;elseseniorCitizen = false;
cout << "Enter the number of personal training sessionsbought : ";cin >> numOfSessions;cout << "Enter the number of months paid for: ";cin >> numOfMonths;}
//Method definition of calcMembershipCostdouble calcMembershipCost(double costPerMonth,double costPerTraining,bool seniorCitizen, int numOfSessions,int numOfMonths){double costMemberShip = costPerMonth * numOfMonths;
if (seniorCitizen){costMemberShip = costMemberShip -(costPerMonth * 0.30 * numOfMonths);}
if (numOfMonths >= 12){costMemberShip = costMemberShip -(costPerMonth * 0.15 * numOfMonths);}
costMemberShip = costMemberShip + (costPerTraining *numOfSessions);
if (numOfSessions > 5){costMemberShip = costMemberShip - (costPerTraining * 0.20 *numOfSessions);}
return costMemberShip;}
Can someone help me fix my code? So it will compute the 2ndtest