Project array & void

I need to do:
1) {Add family membership for $60}
2) Add the code to write new membership accounts to the file "members.txt"
3) {Add choice to view member accounts}
4) Counts of each type of membership processed and display to the console at the end.
TIP - use an array of counters.
I don't get how array will fit in it.

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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 #include <fstream>
#include <iostream>
#include <string>
#include <iomanip> 
using namespace std;

const double ADULT_RATE = 40.0;
const double CHILD_RATE = 20.0;
const double SENIOR_RATE = 30.0;
const double FAMILY_RATE = 60.0;

void displayMenu();
void verifyChoice(int &);
void processChoice(int &);

int main()
{

	int choice;
	do
	{
		displayMenu();
		cin >> choice;
		verifyChoice(choice);
		processChoice(choice);

	} while (choice != 5);
	string data, name;

	ofstream outfile;
	outfile.open("members.txt", std::fstream::app);

	cout << "Writing to the file \n" ;
	cout << "Enter your membership:";
	cin >> name;
	
	outfile << name << endl;
	
	cout << "Enter number of months: ";
	getline(cin, data);
	int months = stoi(data);
	outfile << data << endl;
	int v = processChoice(choice);
	outfile << v << endl;

	outfile.close();
	char c;
	cout << "Do you wish to view member accounts? (Y/N)?";
	cin >> c;
	if (toupper(c) == 'Y')
	{
	
		ifstream infile;
		infile.open("members.txt");
	}
	else
	{
		cout << "...";
	}
	system("pause");
	return 0;
}
void displayMenu(){

	cout << "\n   Health Club Membership Menu\n\n";
	cout << "1. Standard Adult Membership\n";
	cout << "2. Child Membership\n";
	cout << "3. Senior Citizen Membership\n";
	cout << "4. Senior Citizen Membership\n";
	cout << "5. Quit the Program\n\n";
	cout << "Enter your choice: ";
}
void verifyChoice(int &choice)
{

	while ((choice < 1) || (choice > 5))
	{
		cout << "Please enter 1, 2, 3, 4, or 5: ";
		cin >> choice;
	}
}
void processChoice(int &choice)
{
	int months;
	double charges;
	
	if (choice != 5)
	{
		cout << "For how many months? ";
		cin >> months;

		switch (choice)
		{
		case 1: charges = months * ADULT_RATE;
			break;
		case 2: charges = months * CHILD_RATE;
			break;
		case 3: charges = months * SENIOR_RATE;
			break;
		case 4: charges = months * FAMILY_RATE;
		}

		cout << fixed << showpoint << setprecision(2);
		cout << "The total charges are $" << charges << endl;
		
	}
}


Error: I trying to pull processChoice(charges) value
1
2
int v = processChoice(choice);
	outfile << v << endl;

Last edited on
Topic archived. No new replies allowed.