-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildCreditSystem.cpp
More file actions
78 lines (76 loc) · 2.17 KB
/
Copy pathbuildCreditSystem.cpp
File metadata and controls
78 lines (76 loc) · 2.17 KB
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
#include<string>
#include<iostream>
#include<fstream>
#include<unordered_set>
#include<cstdlib>
#include"./csv_parser/csv_reader.h"
#include"./csv_parser/csv_writer.h"
#include"outputToFile.h"
using namespace std;
int buildCreditSystem(){
ifstream icin;
icin.open("../output/result_MapReduce.csv");
vector<string> result;
CSVReader myreader(icin);
myreader.read_next(result);
vector<vector<string>> output;
cout << "set the minimum standard of VIP (amount of consumption):" << endl;
int vip = 0;
cin >> vip;
cout << "set the minimum standard of attractive customer (average amount of each consumption):" << endl;
int attractive = 0;
cin >> attractive;
while (!result.empty()){
myreader.read_next(result);
string name = result[0];
int times = atoi(&result[1][0]);
int amount = atoi(&result[2][0]);
if (amount >= vip){
cout << name << "\tVIP" << endl;
output.push_back(vector<string>{name, "VIP"});
}
else if (amount / times >= attractive){
cout << name << "\tattractive customer" << endl;
output.push_back(vector<string>{name, "attractive customer"});
}
else {
cout << name << "\tgeneral customer" << endl;
output.push_back(vector<string>{name, "general customer"});
}
}
cout << "want to set blacklist? yes or no?" << endl;
string answer = "";
cin >> answer;
if (answer != "yes" && answer != "no"){
cout << "wrong input" << endl;
}
else if (answer == "yes"){
cout << "input the name you want to put into blacklist" << endl;
cout << "enter (q) to quit" << endl;
string blackName = "";
unordered_set<string> blacklist;
while (cin >> blackName){
if (blackName == "q"){
break;
}
blacklist.insert(blackName);
}
cout << "set blacklist...Done" << endl;
for (int i = 0; i < output.size(); ++i){
if (blacklist.find(output[i][0]) != blacklist.end()){
output[i][1] = "blacklist";
}
}
for (int i = 0; i < output.size(); ++i){
cout << output[i][0] << "\t" << output[i][1] << endl;
}
}
cout << "want the software deliver ads automatically? yes or no" << endl;
string ads = "";
cin >> ads;
if (ads == "yes"){
cout << "delivering ads...Done" << endl;
}
outputToFile(output, "../output/creditSystem.csv");
return 0;
}