-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
301 lines (278 loc) · 9.47 KB
/
main.c
File metadata and controls
301 lines (278 loc) · 9.47 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
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
//Supun Suriyaarachchi
// IT20187514
#include <stdio.h> //Include a header file
int main() //Function main begins program execution
{
char sCode, ch = 'Y'; //Initializing and declaring variables
int sCharge = 0, count = 0, numB = 0, Total = 0; //Initializing and declaring variables
int gCode, amount = 0, totAmount = 0, totBill = 0; //Initializing and declaring variables
while ((count < 5) && (ch == 'Y' || ch == 'y')) //loop 5 times and also if (ch = 'Y'/'y')
{
printf(" \n-----------------------------------");
printf(" \nEnter subject code:"); //prompt
scanf(" %c", &sCode); //read subject code from the user
if (sCode == 'M' || sCode == 'm')
{
printf("You have chosen Mathematics\n"); //Display message
printf(" \nEnter grade:"); //prompt
scanf(" %d", &gCode); //read grade from the user
if (gCode == 9)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3500.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3500.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
} //End if
} //End if
else if (sCode == 'S' || sCode == 's')
{
printf("You have chosen Science\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 9)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3500.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3500.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
}
else if (sCode == 'E' || sCode == 'e')
{
printf("You have chosen English\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 9)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3500.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3500.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
}
else if (sCode == 'H' || sCode == 'h')
{
printf("You have chosen History\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 9)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 2500.0;
}
else if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
}
else if (sCode == 'G' || sCode == 'g')
{
printf("You have chosen Geography\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 9)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 2000.0;
}
else if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 2500.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 2500.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
}
else if (sCode == 'L' || sCode == 'l')
{
printf("You have chosen English literature\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
}
else if (sCode == 'B' || sCode == 'b')
{
printf("You have chosen Business studies\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
}
else if (sCode == 'I' || sCode == 'i')
{
printf("You have chosen Information and Communication technology\n");
printf(" \nEnter grade:");
scanf(" %d", &gCode);
if (gCode == 10)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else if (gCode == 11)
{
printf(" \nEnter number of past paper bundles needed:");
scanf(" %d", &numB);
amount = numB * 3000.0;
}
else
{
printf("\nInvalid grade\n");
printf("Please try again\n");
count--;
amount = 0;
}
} //End else if
else
{
printf("\nInvalid subject code\n");
printf("Please try again\n");
count--;
amount = 0;
} //End else
count++;
if (count == 5)
{
printf("\nYou have entered the maximum number of orders\n");
totAmount = totAmount + amount;
break;
} //End if
else
{
printf("\nDo you want more past paper bundles (Y/N)?\n");
scanf("%*c%c", &ch);
} //End else
totAmount = totAmount + amount; //Calculate totAmount
} //End while
printf("\n-----------------------------------\n");
totBill = totBill + totAmount; //Calculate totBill
sCharge = totBill * 10 / 100; //Calculate sCharge (service charge)
Total = totBill + sCharge; //Calculate Total
printf(" Order has been placed successfully\n");
printf(" Your delivery is on the way\n");
printf(" Thank you for choosing 'Wisdom'\n");
printf("\n"); //line spacing
printf(" Sub total = Rs.%.2d\n", totBill); //Displaying the sub total
printf(" Service charge = Rs.%.2d\n", sCharge); //Displaying service charge
printf("\n");
printf(" Total Amount= Rs.%.2d\n", Total); //Displaying the total amount
return 0;
} //End of main function