-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeniorCitizenOutingManager.cpp
More file actions
204 lines (183 loc) Β· 7.03 KB
/
SeniorCitizenOutingManager.cpp
File metadata and controls
204 lines (183 loc) Β· 7.03 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// ================================
// Title: Senior Citizens Outing Management System
// Description:
// This program manages the outing of senior citizens by:
// - Gathering outing information
// - Recording participants and their payments
// - Calculating outing costs and profits/losses
// ================================
#include<iostream>
#include<cmath>
using namespace std;
// Global Variables
int total_citizens; // Total number of citizens going for outing
int Cares_for_outing = 0; // Number of carers required
// ================================
// Class: Citizen_information
// Purpose: Handles citizen outing input and cost calculations
// ================================
class Citizen_information
{
protected:
double total_cost_meal;
double cost_for_coach;
double cost_for_tickets;
double Total_cost;
public:
// Set default carers for outing
int set_Care_for_outing(int care_by_default)
{
Cares_for_outing = care_by_default;
return Cares_for_outing;
}
// Get user input and validate number of citizens
void Citizens_Information()
{
cout << "\n Enter total Number of Citizens for Outing: ";
cin >> total_citizens;
// Validation: between 10 and 36 (exclusive)
while (total_citizens < 10 || total_citizens >= 36)
{
cout << "\n Minimum Citizens required to go out for outing is 10.\n";
cout << "Enter valid Number of Citizens (10-35): ";
cin >> total_citizens;
}
// Assign carer if citizens > 24
if (total_citizens > 24)
{
Cares_for_outing++;
}
}
// Calculate total cost for outing based on slabs
int calculate_information(int total_citizens)
{
cout << "\n Calculated Total Cost of Outing Through " << total_citizens << " citizens.\n";
// Cost slabs
if (total_citizens >= 11 && total_citizens <= 16)
{
total_cost_meal = 14.00;
cost_for_coach = 150;
cost_for_tickets = 21.00;
}
else if (total_citizens >= 17 && total_citizens <= 26)
{
total_cost_meal = 13.50;
cost_for_coach = 190;
cost_for_tickets = 20.00;
}
else if (total_citizens >= 27 && total_citizens <= 36)
{
total_cost_meal = 13.00;
cost_for_coach = 225;
cost_for_tickets = 19.00;
}
// Total cost calculated
Total_cost = total_citizens * total_cost_meal * cost_for_tickets;
return Total_cost;
}
};
// ================================
// Class: ParticipantRecorder
// Purpose: Records participant details and calculates total amount paid
// ================================
class ParticipantRecorder {
public:
int recordParticipants(int total_citizens) {
string names[total_citizens + Cares_for_outing]; // Combined array for citizens and carers
double amountsPaid_for_meal[total_citizens + Cares_for_outing] = {0};
double amountsPaid_for_ticket[total_citizens + Cares_for_outing] = {0};
// Display cost slabs
cout << "\n______________________________________________________________\n";
cout << "\nNo of people : Cost for Meal : Ticket Amount\n";
cout << "12-16 : $14.00 : $21.00\n";
cout << "17-26 : $13.50 : $20.00\n";
cout << "27-36 : $13.00 : $19.00\n";
cout << "______________________________________________________________\n";
// Input names and payments for senior citizens
for (int i = 0; i < total_citizens; i++) {
cout << "\nEnter name of Senior Citizen " << i + 1 << ": ";
cin >> names[i];
cout << "Enter amount for meal paid by " << names[i] << ": ";
cin >> amountsPaid_for_meal[i];
cout << "Enter amount for ticket paid by " << names[i] << ": ";
cin >> amountsPaid_for_ticket[i];
}
// Input names of carers (no cost input assumed)
for (int i = 0; i < Cares_for_outing; i++) {
cout << "\nEnter name of Carer " << i + 1 << ": ";
cin >> names[total_citizens + i];
}
// Display all participants and amount paid
cout << "\n\nList of Participants and Amounts Paid:\n";
for (int i = 0; i < total_citizens; i++) {
cout << names[i] << "\t $ " << amountsPaid_for_meal[i] + amountsPaid_for_ticket[i] << endl;
}
for (int i = total_citizens; i < total_citizens + Cares_for_outing; i++) {
cout << names[i] << "\t $0.00 (Carer)\n";
}
// Calculate total collected amount
double totalAmountCollected = 0;
for (int i = 0; i < total_citizens; i++) {
totalAmountCollected += amountsPaid_for_meal[i] + amountsPaid_for_ticket[i];
}
cout << "\nTotal Amount Collected: $" << totalAmountCollected << endl;
return totalAmountCollected;
}
};
// ================================
// Class: OutingProfitCalculator
// Purpose: Calculates profit or loss from outing
// ================================
class OutingProfitCalculator {
public:
void calculateProfit(double totalCost, double totalAmountCollected) {
if (totalAmountCollected >= totalCost) {
double profit = totalAmountCollected - totalCost;
cout << "\nThe outing has made a profit of $" << profit << endl;
} else {
double loss = totalCost - totalAmountCollected;
cout << "\nThe outing has incurred a loss of $" << loss << endl;
}
}
};
// ================================
// Function: main()
// Purpose: User interaction and menu
// ================================
int main() {
Citizen_information citizenInfo;
ParticipantRecorder participantRecorder;
OutingProfitCalculator profitCalculator;
int choice;
double total_cost = 0, user_cost = 0;
do {
// Menu options
cout << "\n=================== MENU ===================";
cout << "\n1. Enter Citizens Information (Task 1)";
cout << "\n2. Record Participants (Task 2)";
cout << "\n3. Calculate Profit (Task 3)";
cout << "\n4. Exit";
cout << "\nEnter your choice: ";
cin >> choice;
// Handle user choice
switch (choice) {
case 1:
citizenInfo.Citizens_Information();
citizenInfo.set_Care_for_outing(2); // Set default carers
total_cost = citizenInfo.calculate_information(total_citizens);
break;
case 2:
user_cost = participantRecorder.recordParticipants(total_citizens);
break;
case 3:
profitCalculator.calculateProfit(total_cost, user_cost);
break;
case 4:
cout << "Exiting program...\n";
break;
default:
cout << "Invalid choice! Please enter a valid option.\n";
}
} while (choice != 4);
return 0;
}