Can't figure it out

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.txt Preview 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.



The program won't go past the first user answer in visual studio.

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
77
 

#include "pch.h"
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <time.h>

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 numCost, enter;
	cin >> enter;

	if (enter == 1) {
		numCost = 500;
	}
	else if (enter == 2) {
		numCost = 800;
	}
	else if (enter == 3) {
		numCost = 1200;
	}

	if (myfile.is_open())
	{
		while (getline(myfile, line))
		{
			

			string delimiter = ":";

			int pos = 0;
			string token;
			while ((pos = line.find(delimiter)) != string::npos) {
				token = line.substr(0, pos);
				
				line.erase(0, pos + delimiter.length());
			}

			if (token == "Cafe")
				cout << "Arrangement 1:- Discounts: " << (numCost*0.01) << " Service: " << token << " Benefits: " << line << endl;
			else if (token == "SPA")
				cout << "Arrangement 2:- Discounts: " << (numCost*0.10) << " Service: " << token << " Benefits: " << line << endl;
			else if (token == "Training")
				cout << "Arrangement 3:- Discounts: " << (numCost*0.15) << " Service: " << token << " Benefits: " << line << endl;
			else if (token == "Aquatics" && numCost == 1200)
				cout << "Arrangement 4:- Discounts: " << " No discount" << " Service: " << token << " Benefits: " << line << endl;
		}
		myfile.close();

		if (numCost != 1200) {
			srand(time(NULL));
			int r = rand() % 3 + 1;
			cout << "You are going to get Arrangement Number " << r << " this month" << endl;
		}
		else {
			srand(time(NULL));
			int r = rand() % 4 + 1;
			cout << "You are going to get Arrangement Number " << r << " this month" << endl;
		}
	}

	return 0;
}
closed account (E0p9LyTq)
Duplicate topic
http://www.cplusplus.com/forum/beginner/243957/
Topic archived. No new replies allowed.