Suppose the membership at a fitness club is $500 for individual, $800 for couple and $1200 for 4 people. Every month, the manager at the club says that guests will get discounts for one service per month. He provides you with the list of services that will get a discount:
Your program will be reading in a file which contains a list of services at a fitness club. The discount is determined by the type of service. For example, the file is as follows:
Cafe: Smoothies
SPA: Hair and Skin
Training: 90 day challenge
Aquatics: Kids free training session
Your program should read this file and offer this discount:
If the service is Cafe, then discount is 1% of annual fitness club fee.
If the service is SPA, then discount is 10% of the annual fitness club fee.
If the service is Training, then discount is 15% of the annual fitness club fee.
If the service is Aquatics, then no discount, but program should only offer it for the family memberships.
Your program should ask the user what type of membership they have. Based on the type of membership, your program should calculate the dollar amount discount per service and list all applicable services and benefits for that user.
Your program should be reading the file in and calculating the benefits based on the type of membership. Your program should also randomly pick among the 4 discounts or 3 depending on the type of membership and display which discount the member gets for this month.
Here is the file: services.txtPreview the document
Create an algorithm.
Program and save as FitnessMembershipYourName.cpp. Make sure to include the algorithm and comment your code! Make sure you meet all the requirements specified above.
Show minimum 3 test cases as screenshots in a PDF file: FitnessMembershipYourName.pdf
I have gotten this but it won't go any further than the first user answer. I don't understand what's wrong.
service.txt:
Cafe:Smoothies
SPA:Hair and Skin
Training:90 day challenge
Aquatics:Kids free training session
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include "pch.h"
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <string>
#include <math.h>
#include <fstream>
#include <sstream>
using namespace std;
int main() {
string line;
ifstream myfile("services.txt");
cout << "Enter the type of membership you have: " << endl;
cout << " 1-for Individual" << endl;
cout << " 2-for Couple" << endl;
cout << " 3-for 4 people" << endl;
int amnt, enter;
cin >> enter;
if (enter == 1)
amnt = 500;
else if (enter == 2)
amnt = 800;
else if (enter == 3)
amnt = 1200;
if (myfile.is_open())
{
while (getline(myfile, line))
{
cout << line << '\n';
string delimiter = ":";
int pos = 0;
string token;
while ((pos = line.find(delimiter)) != string::npos) {
token = line.substr(0, pos);
cout << token << endl;
line.erase(0, pos + delimiter.length());
}
if (token == "Cafe")
cout << "Scheme(1):- Discounts: " << (amnt*0.01) << " Service: " << token << " Benefits: " << line << endl;
else if (token == "SPA")
cout << "Scheme(2):- Discounts: " << (amnt*0.10) << " Service: " << token << " Benefits: " << line << endl;
else if (token == "Training")
cout << "Scheme(3):- Discounts: " << (amnt*0.15) << " Service: " << token << " Benefits: " << line << endl;
else if (token == "Aquatics" && amnt == 1200)
cout << "Scheme(4):- Discounts: " << " No discount" << " Service: " << token << " Benefits: " << line << endl;
}
myfile.close();
if (amnt != 1200) {
srand(time(NULL));
int r = rand() % 3 + 1;
cout << "You are going to get Scheme Number " << r << " this month" << endl;
}
else {
srand(time(NULL));
int r = rand() % 4 + 1;
cout << "You are going to get Scheme Number " << r << " this month" << endl;
}
}
return 0;
}
|