-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdriver.cpp~
307 lines (234 loc) · 6.89 KB
/
driver.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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
// Raquel Figueroa
// Ali Fenton
// David Jia
// Daniel Calderon
#include<iostream> // input output
#include<string> // string
#include <cctype>
#include <cassert>
double scuba(int peopleTotal, int totalDays);
double discount(double baseChange);
char menu();
double climbing( );
double scuba(int peopleTotal, int totalDays);
double skyDive();
double spelunk();
double discount(double baseChange); // gives discounted price
using namespace std;
int main()
{
if(menu() == 'a')
{
cout << climbing()<<endl;
}
// else if(menu() =='b')
// {
// scuba();
// }
else if(menu() =='c')
{
cout << skyDive()<<endl;
}
else if(menu() =='d')
{
cout << spelunk() << endl;
}
return 0;
}
char menu()
{
char ans;
cout << "\n"
<< "**Welcome to High Adventure Travel Agency**\n"
<< " We offer 4 vacation packages:\n"
<< " A. Devil's Courthouse Adventure Weekend.\n"
<< " B. Scuba Bahama.\n"
<< " C. Sky Dive Colorado.\n"
<< " D. Barron Cliff Spelunk.\n"
<< "\n"
<< "Please enter your preferred vacation package: ";
cin >> ans;
ans = tolower(ans);
while (ans != 'a' && ans != 'b' && ans != 'c' && ans != 'd')
{
cout << "\n"
<< "Invalid input. Please choose A, B, C, or D: ";
cin >> ans;
ans = tolower(ans);
}
return ans;
}
double spelunk()
{
int numPeople(0), numEquipRental(0), numDays(0);
double totalBaseCharge(0), totalEquipRental(0), totalCost(0);
double costBaseCharge(700), costEquipRental(40), discount(0.9);
cout << "You have chosen the Barron Cliff Spelunk Vacation Package!"
<< "\n"
<< "Enter number of people: ";
cin >> numPeople;
cout << "Enter the number of people renting equipment: ";
cin >> numEquipRental;
cout << "Enter number of days you will need the equipment: ";
cin >> numDays;
totalBaseCharge = costBaseCharge * numPeople;
totalEquipRental = costEquipRental * numDays * numEquipRental;
if (numPeople >= 5)
totalBaseCharge = totalBaseCharge * discount;
totalCost = totalBaseCharge + totalEquipRental;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
return totalCost;
}
//double discount(double baseChange)
//{
// return (baseChange * 0.9);
//}
double climbing()
{
int numPeople, numInstructions, numRentals, numRentalDays;
double basePrice = 350;
int instructionPrice = 100;
int rentalPrice = 40;
double baseCharge, instructionCharge, rentalCharge, totalCharge;
cout << "How many people will be attending?" << endl;
cin >> numPeople;
while (numPeople < 1) // checks for invalid input
{
cout << "Please enter a valid number of people attending or zero if you wish to cancel."
<< endl;
cin >> numPeople;
if (numPeople == 0)
{
return 0;
}
}
cout << "How many people will be needing climbing instructions?" << endl;
cin >> numInstructions;
while (numInstructions < 0)
{
cout << "Please enter a valid number of people that need climbing instruction or " <<
"enter zero if no one needs climbing instruction." << endl;
cin >> numInstructions;
}
cout << "How many people need equipment rental?" << endl;
cin >> numRentals;
while (numRentals < 0)
{
cout << "Please enter a valid number of people that need equipment rental or " <<
" enter zero if no one needs equipment rental." << endl;
cin >> numRentals;
}
if (numRentals > 1)
{
cout << "How many days do you wish to rent the equipment for?" << endl;
cin >> numRentalDays;
while (numRentalDays < 0)
{
cout << "Please enter a valid number for the number of days desired for the " <<
" equipment rental or enter zero to cancel the rental." << endl;
cin >> numRentalDays;
}
}
baseCharge = basePrice * numPeople;
if (numPeople >= 5)
{
baseCharge = discount(baseCharge);
}
instructionCharge = instructionPrice * numInstructions;
rentalCharge = rentalPrice * numRentals * numRentalDays;
cout.setf(ios::fixed); // gives back 2 decimal places
cout.setf(ios::showpoint);
cout.precision(2);
totalCharge = baseCharge + instructionCharge + rentalCharge;
return totalCharge;
}
double discount(double baseCharge){
return(baseCharge * 0.9);
}
double scuba(int peopleTotal, int totalDays){
int baseCharge = 1000;
int scubaInstruc = 100;
int totalOfScuba;
if(peopleTotal >= 5){
baseCharge = discount(baseCharge);
}
baseCharge = baseCharge * peopleTotal;
if(totalDays >= 1){
scubaInstruc = scubaInstruc * peopleTotal;
scubaInstruc = scubaInstruc * totalDays;
}
totalOfScuba = scubaInstruc + baseCharge;
return totalOfScuba;
}
double skyDive()
{
int numPeople, numLodge, numLodgeDays, numInn, numInnDays;
double basePrice = 700;
int lodgePrice = 65;
int innPrice = 120;
double baseCharge, lodgeCharge, innCharge, totalCharge;
cout << "How many people will be attending?" << endl;
cin >> numPeople;
while (numPeople < 1) // checks for invalid input
{
cout << "Please enter a valid number of people attending or zero if you wish to cancel."
<< endl;
cin >> numPeople;
if (numPeople == 0)
{
return 0;
}
}
cout << "How many people would like to stay at the Wilderness Lodge?" << endl;
cin >> numLodge;
while (numLodge < 0) // checks for invalid input
{
cout << "Please enter a valid number of people staying or zero if you wish to cancel."
<< endl;
cin >> numLodge;
}
if (numLodge > 1)
{
cout << "How many days do they wish to stay at the Wilderness Lodge?" << endl;
cin >> numLodgeDays;
while (numLodgeDays < 0) // checks for invalid input
{
cout << "Please enter a valid number of days staying or zero if you wish to cancel."
<< endl;
cin >> numLodgeDays;
}
}
cout << "How many people would like to stay at the Luxury Inn?" << endl;
cin >> numInn;
while (numInn < 0) // checks for invalid input
{
cout << "Please enter a valid number of people staying or zero if you wish to cancel."
<< endl;
cin >> numInn;
}
if (numInn > 1)
{
cout << "How many days do they wish to stay at the Luxury Inn?" << endl;
cin >> numInnDays;
while (numInnDays < 0) // checks for invalid input
{
cout << "Please enter a valid number of days staying or zero if you wish to cancel."
<< endl;
cin >> numInnDays;
}
}
baseCharge = basePrice * numPeople;
if (numPeople >= 5)
{
baseCharge = discount(baseCharge);
}
lodgeCharge = lodgePrice * numLodge * numLodgeDays;
innCharge = innPrice * numInn * numInnDays;
cout.setf(ios::fixed); // gives back 2 decimal places
cout.setf(ios::showpoint);
cout.precision(2);
totalCharge = baseCharge + lodgeCharge + innCharge;
return totalCharge;
}