-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHW4.cpp
316 lines (266 loc) · 10.6 KB
/
HW4.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
308
309
310
311
312
313
314
315
316
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
// int main(){
// char carChoice;
// cout << "Enter the first letter of the company: " << endl;
// cin >> carChoice;
// switch (carChoice){
// case 'B':
// cout << "Automobile manufacturer chosen: BMW" << endl;
// break;
// case 'V':
// cout << "Automobile manufacturer chosen: Volkswagen" << endl;
// break;
// case 'H':
// cout << "Automobile manufacturer chosen: Honda" << endl;
// break;
// case 'T':
// cout << "Automobile manufacturer chosen: Tesla" << endl;
// break;
// default:
// cout << "Automobile manufacturer chosen: Invalid" << endl;
// break;
// }
// }
// int main(){
// int categChoice, instrumentChoice;
// cout << "Select a category: (1)Brass (2)Woodwind (3)Percussion" << endl;
// cin >> categChoice;
// switch (categChoice){
// case 1:
// cout << "Select an instrument: (1)Trumpet (2)Trombone" << endl;
// cin >> instrumentChoice;
// switch (instrumentChoice){
// case 1:
// cout << "Your instrument will be $570." << endl;
// break;
// case 2:
// cout << "Your instrument will be $500." << endl;
// break;
// default:
// cout << "Please enter a valid input." << endl;
// break;
// }
// break;
// case 2:
// cout << "Select an instrument: (1)Flute (2)Saxophone" << endl;
// cin >> instrumentChoice;
// switch (instrumentChoice){
// case 1:
// cout << "Your instrument will be $425." << endl;
// break;
// case 2:
// cout << "Your instrument will be $225." << endl;
// break;
// default:
// cout << "Please enter a valid input." << endl;
// break;
// }
// break;
// case 3:
// cout << "Select an instrument: (1)Snare Drum (2)Cymbals" << endl;
// cin >> instrumentChoice;
// switch (instrumentChoice){
// case 1:
// cout << "Your instrument will be $275." << endl;
// break;
// case 2:
// cout << "Your instrument will be $350." << endl;
// break;
// default:
// cout << "Please enter a valid input." << endl;
// break;
// }
// break;
// default:
// cout << "Please enter a valid input." << endl;
// break;
// }
// }
// int main(){
// int genre, director, movie;
// cout << "Select the genre: (1) Animation (2) Adventure" << endl;
// cin >> genre;
// switch (genre){
// case 1:
// cout << "Select the director: (1) Pete Docter (2) Brad Bird (3) Andrew Stanton" << endl;
// cin >> director;
// switch (director){
// case 1:
// cout << "Select the movie: (1) Monsters, Inc. (2) Inside Out" << endl;
// cin >> movie;
// switch (movie){
// case 1:
// cout << "You have reserved the movie: Monsters, Inc." << endl;
// break;
// case 2:
// cout << "You have reserved the movie: Inside Out" << endl;
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// case 2:
// cout << "Select the movie: (1) The Incredibles (2) Ratatouille" << endl;
// cin >> movie;
// switch (movie){
// case 1:
// cout << "You have reserved the movie: The Incredibles" << endl;
// break;
// case 2:
// cout << "You have reserved the movie: Ratatouille" << endl;
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// case 3:
// cout << "Select the movie: (1) Finding Nemo (2) WALL-E" << endl;
// cin >> movie;
// switch (movie){
// case 1:
// cout << "You have reserved the movie: Finding Nemo" << endl;
// break;
// case 2:
// cout << "You have reserved the movie: WALL-E" << endl;
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// case 2:
// cout << "Select the director: (1) Steven Spielberg (2) Jon Favreau (3) Robert Zemeckis" << endl;
// cin >> director;
// switch (director){
// case 1:
// cout << "Select the movie: (1) E.T. the Extra-Terrestrial (2) The BFG" << endl;
// cin >> movie;
// switch (movie){
// case 1:
// cout << "You have reserved the movie: E.T. the Extra-Terrestrial" << endl;
// break;
// case 2:
// cout << "You have reserved the movie: The BFG" << endl;
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// case 2:
// cout << "Select the movie: (1) The Jungle Book (2016) (2) Elf" << endl;
// cin >> movie;
// switch (movie){
// case 1:
// cout << "You have reserved the movie: The Jungle Book (2016)" << endl;
// break;
// case 2:
// cout << "You have reserved the movie: Elf" << endl;
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// case 3:
// cout << "Select the movie: (1) Back to the Future (2) Who Framed Roger Rabbit" << endl;
// cin >> movie;
// switch (movie){
// case 1:
// cout << "You have reserved the movie: Back to the Future" << endl;
// break;
// case 2:
// cout << "You have reserved the movie: Who Framed Roger Rabbit" << endl;
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// break;
// default:
// cout << "Please enter a valid input" << endl;
// break;
// }
// }
// double calculateRoomArea(double length, double width);
// double calculateRoomArea(double length, double width){
// if (length <= 0 || width <= 0){
// cout << "Length or width is invalid. Area cannot be calculated." << endl;
// return -1;
// }
// else {
// double area = length*width;
// return area;
// }
// }
// int main(){
// double lchoice, wchoice;
// cout << "Enter the length of the room in ft:" << endl;
// cin >> lchoice;
// cout << "Enter the width of the room in ft:" << endl;
// cin >> wchoice;
// double area = calculateRoomArea(lchoice, wchoice);
// if (area > 0){
// cout << "The area is: " << area << " sq ft." << endl;
// }
// else{
// return 0;
// }
// }
double calculateSowingTime(double area, char machine_type);
double calculateSowingTime(double area, char machine_type){
if ((area > 0 && area != 0) && ((machine_type == 'W') || (machine_type == 'X') || (machine_type == 'Y') || (machine_type == 'Z'))){
return 1;
}
else{
cout << "Area or machine type is invalid. Time cannot be calculated." << endl;
return 0;
}
}
int main(){
double farmArea;
char sowMachine;
cout << "Enter area of the farmland in sq ft:" << endl;
cin >> farmArea;
cout << "Enter the type of sowing machine to be used:" << endl;
cin >> sowMachine;
double time = calculateSowingTime(farmArea, sowMachine);
if (time == 1){
switch (sowMachine){
case 'W':
time = farmArea/(8.0/12.0);
cout << "The time taken is: " << time << " minutes." << endl;
break;
case 'X':
time = farmArea/(3.0/10.0);
cout << "The time taken is: " << time << " minutes." << endl;
break;
case 'Y':
time = farmArea/(2.0/7.0);
cout << "The time taken is: " << time << " minutes." << endl;
break;
case 'Z':
time = farmArea/(7.0/8.0);
cout << "The time taken is: " << time << " minutes." << endl;
break;
}
}
else{
return 0;
}
}