-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathratingApp.cpp
More file actions
86 lines (79 loc) · 1.81 KB
/
Copy pathratingApp.cpp
File metadata and controls
86 lines (79 loc) · 1.81 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
79
80
81
82
83
84
85
86
#include <iostream>
using namespace std;
int main()
{
// Initilize variables
int ratingSum = 0;
int ratingCount = 0;
int rateHighest = 0;
int rateLowest = 5;
while (true) // our main loop
{
// display menu
cout << endl;
cout << "Welcome to China Border Protection" << endl;
cout << "===== Satisfaction Survey ========" << endl;
cout << "1- Submit Rating" << endl;
cout << "2- View Rating" << endl;
cout << "3- Reset Rating" << endl;
cout << "0- Exit" << endl;
int choice;
cout << "Your choice? ";
cin >> choice;
// Submit Rating feature
if (choice == 1)
{
int rating;
cout << "Your rating (1-4)? ";
cin >> rating;
if (rating > 0 && rating < 5)
{
ratingCount++; // increment number of ratings
ratingSum += rating; // add rating to the rating sum
if (rating > rateHighest)
{
rateHighest = rating;
}
if (rating < rateLowest)
{
rateLowest = rating;
}
cout << "Your rating is recorded." << endl;
}
else
{
cout << "You must enter a number from 1 to 4." << endl;
}
}
// View Rating feature
else if (choice == 2)
{
if (ratingCount == 0)
{
cout << "There are no ratings for this officer yet." << endl;
}
else
{
cout << "Highest Rating: " << rateHighest << endl;
cout << "Lowest Rating: " << rateLowest << endl;
int avg = ratingSum / ratingCount;
cout << "Average Rating: " << avg << endl;
}
}
// Reset Rating feature
else if (choice == 3)
{
ratingCount = 0;
ratingSum = 0;
rateHighest = 0;
rateLowest = 5;
cout << "The ratings for this officer is reset." << endl;
}
// Exit feature
else if (choice == 0)
{
cout << "Thank you for using CBPSS v1.0" << endl;
break;
}
}
}