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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply