-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_9.cpp
65 lines (51 loc) · 1.1 KB
/
6_9.cpp
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
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct Patrons
{
string name;
double money;
};
const int SIZE = 50;
int main()
{
char fileName[SIZE];
fstream inFile;
cout << "Enter the name of the input file: ";
cin.getline(fileName, SIZE);
inFile.open(fileName);
if(!inFile.is_open())
{
cout << "Could not open the file " << fileName << endl;
cout << "Program Terminated." << endl;
exit(EXIT_FAILURE);
}
int number = 0;
inFile >> number;
inFile.get();
// cout << number << "patrons." << endl;
Patrons * patrons = new Patrons[number];
for(int i = 0; i < number; i++)
{
getline(inFile, patrons[i].name);
inFile >> patrons[i].money;
inFile.get();
}
cout << "Grand Patron: " << endl;
for(int j = 0; j < number; j++)
{
if(10000 < patrons[j].money)
cout << patrons[j].name << endl;
}
cout << "Patron: " << endl;
for(int k = 0; k < number; k++)
{
if(10000 >= patrons[k].money)
cout << patrons[k].name << endl;
}
delete [] patrons;
inFile.close();
// system("pause");
return 0;
}