repl.it
@SofhinWong1/

assignment

C

No description

fork
loading
Files
  • main.c
main.c
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#include <stdio.h>
#include<string.h>
#include<stdlib.h>

void Room_Type(){
  printf("\n1 Single Room\n2 Double Bedded Room\n3 Triple Bedded Room\n4 Four Beeded Room\n5 Main Menu\nPlease enter your option: ");}

int main(){
//variable for menu1
int menu, GDR,i,pay,Laundry_rate=20;
//variables for A1
char *A1_Name=malloc(100);
char *A1_SID=malloc(100);
char *A1_Room=malloc(100);
int choose,I_week, L_week,R_week;
int A1_Internet, A1_Laundry, A1_Gym, A1_Meal,A1_total;
int A1_room_rate=400, A1_Internet_rate=40;

//variables for A3
char*A3_Name=malloc(100);
char *A3_SID=malloc(100);
char *A3_Room=malloc(100);
int A3_Internet, A3_Laundry, A3_Gym, A3_Meal, A3_room_rate=150, A3_Internet_rate=15;
int A3_L_week, A3_I_week, A3_R_week,A3_total;

//variables for A4
char *A4_Name=malloc(100);
char *A4_SID=malloc(100);
char *A4_Room=malloc(100);
int A4_Internet, A4_Laundry, A4_Gym, A4_Meal, A4_room_rate=100, A4_Internet_rate=10;
int A4_L_week, A4_I_week, A4_R_week,A4_total;

//variable for B4
char *B4_Name=malloc(100);
char *B4_SID=malloc(100);
char *B4_Room=malloc(100);
int B4_Internet, B4_Laundry, B4_Gym, B4_Meal, B4_room_rate=100, B4_Internet_rate=10;
int B4_L_week, B4_I_week, B4_R_week,B4_total;

//variable for menu2
int check;

int I_total, room_total, L_total,total;

for(i=0;i<=2;i++){
  A1_Room[i]=0;
  A3_Room[i]=0;
  A4_Room[i]=0;
  B4_Room[i]=0;
  I_total=0;
  L_total=0;
  room_total=0;
  A1_total=0;
  A3_total=0;
  A4_total=0;
  B4_total=0;}

Main_Menu:
  printf("\n1 Room Booking\n2 Room Availability\n3 Payment Details\nPlease enter your option:");
  scanf("%i",&menu);

  if(menu==1)
  {
  Details:
    printf("\n\n1 Male\n2 Female\nPlease enter your option: ");
    scanf("%i",&GDR);
    Room_Type();
    scanf("%i", & choose);}

//male+A1
    if(GDR==1 && choose==1){
      A1:
      printf("\nHow many weeks of room booking?\n");
      scanf("%i",&R_week);

Internet1:
        printf("\nDo you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
        scanf("%i",&A1_Internet);
        if(A1_Internet==1){
          printf("How many weeks of subscription?\n");
          scanf("%i",&I_week);
          goto Meal1;} 
        if(A1_Internet==2){
          A1_Internet=0;}
        else{
          goto Internet1;
        }

Meal1:
        printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
        scanf("%i",&A1_Meal);
        if(A1_Meal==1){
          printf("\nSorry, this service is not available for subscription. Thank you.\n");
          goto Laundry1;}
        if(A1_Meal ==2){
          goto Laundry1;}
        else{
          goto Meal1;}

Laundry1:
        printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
        scanf("%i",&A1_Laundry);
        if(A1_Laundry==1){
          printf("How many weeks of subscription?\n");
          scanf("%i",&L_week);
          goto Gym1;}
        if(A1_Laundry==2){
          A1_Laundry=0;}
        else{
          goto Laundry1;}
Gym1:
        printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
        scanf("%i",&A1_Gym);
        if(A1_Gym==1){
          printf("\nSorry, this service is not available for subscription. Thank you\n");
          goto Info1;}
        if(A1_Gym==2){
          goto Info1;}
        else{
          goto Gym1;}
Info1:      
        printf("\nPlease enter your name:");
        scanf("%s", A1_Name);
        printf("Please enter your Student ID:");
        scanf("%s",A1_SID);
        room_total= A1_room_rate*R_week;
        L_total = Laundry_rate*L_week;
        I_total = A1_Internet_rate*I_week;
        total = room_total + I_total+L_total;
      
      Pay:
        printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A1_room_rate, R_week, room_total, Laundry_rate,L_week,L_total,A1_Internet_rate,I_week,I_total,total);
        printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
        scanf("%i",&pay);
        if(pay==1){
          printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
          printf("Thank you for your payment.\n\n");
          goto Main_Menu;}
        if(pay==2){
          printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
          goto Main_Menu;}
        else{
          goto Pay;}}
//male+A2    
    if(GDR==1 && choose==2){
      A2:
      printf("\nSorry. This block is not ready for occupancy.");
      goto Details;}  
//male+A3
    if(GDR==1 && choose==3){
      A3:
      printf("\nHow many weeks of room booking?\n");
      scanf("%i",&A3_R_week);

Internet2:
      printf("\nDO you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A3_Internet);
      if(A3_Internet==1){
        printf("How many weeks of subscription?\n");
        scanf("%i",&A3_I_week);
        goto Meal2;}
      if(A3_Internet==2){
        A3_Internet=0;}
      else{
        goto Internet2;}

Meal2:
      printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A3_Meal);
      if(A3_Meal==1){
        printf("\nSorry, this service is not available for subscription. Thank you.\n");
        goto Laundry2;}
      if(A3_Meal==2){
        goto Laundry2;}
      else{
        goto Meal2;}

Laundry2:
      printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A3_Laundry);
      if(A3_Laundry==1){
        printf("How many weeks of subscription?\n");
        scanf("%i",&A3_L_week);
        goto Gym2;}
      if(A3_Laundry==2){
        A3_Laundry=0;}
      else{
        goto Laundry2;}

Gym2:
      printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A3_Gym);
      if(A3_Gym==1){
        printf("Sorry, this service is not available for subscription. Thank you\n");
        goto Info2;}
      if(A3_Gym==2){
        goto Info2;}
      else{
        goto Gym2;}

Info2:
      printf("\nPlease enter your name:");
      scanf("%s", A3_Name);
      printf("Please enter your Student ID:");
      scanf("%s",A3_SID);
      room_total= A3_room_rate*A3_R_week;
      L_total = Laundry_rate*A3_L_week;
      I_total = A3_Internet_rate*A3_I_week;
      A3_total = room_total + I_total+L_total;
    
    Pay2:
      printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A3_room_rate, A3_R_week, room_total, Laundry_rate,A3_L_week,L_total,A3_Internet_rate,A3_I_week,I_total,A3_total);
      printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
      scanf("%i",&pay);
      if(pay==1){
        printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
        printf("Thank you for your payment.\n\n");
        goto Main_Menu;}
      if(pay==2){
        printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
        goto Main_Menu;}
      else{
        goto Pay2;}}

//male+A4
    if(GDR==1 && choose==4){
      A4:
      printf("\nHow many weeks of room booking?\n");
      scanf("%i",&A4_R_week);

Internet3:
      printf("\nDO you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A4_Internet);
      if(A4_Internet==1){
        printf("How many weeks of subscription?\n");
        scanf("%i",&A4_I_week);
        goto Meal3;}
      if(A4_Internet==2){
        A4_Internet=0;}
      else{
        goto Internet3;}

Meal3:
      printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A4_Meal);
      if(A4_Meal==1){
        printf("Sorry, this service is not available for subscription. Thank you.\n");
        goto Laundry3;}
      if(A4_Meal==2){
        goto Laundry3;}
      else{
        goto Meal3;}

Laundry3:
      printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A4_Laundry);
      if(A4_Laundry==1){
        printf("How many weeks of subscription?\n");
        scanf("%i",&A4_L_week);
        goto Gym3;}
      if(A4_Laundry==2){
        A4_Laundry=0;}
      else{
        goto Laundry3;}
Gym3:
      printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&A4_Gym);
      if(A4_Gym==1){
        printf("Sorry, this service is not available for subscription. Thank you\n");
        goto Info3;}
      if(A4_Gym==2){
        goto Info3;}
      else{
        goto Gym3;}

Info3:
      printf("\nPlease enter your name:");
      scanf("%s", A4_Name);
      printf("Please enter your Student ID:");
      scanf("%s",A4_SID);
      room_total= A4_room_rate*A4_R_week;
      L_total = Laundry_rate*A4_L_week;
      I_total = A4_Internet_rate*A4_I_week;
      A4_total = room_total + I_total+L_total;
    
    Pay3:
      printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A4_room_rate, A4_R_week, room_total, Laundry_rate,A4_L_week,L_total,A4_Internet_rate,A4_I_week,I_total,A4_total);
      printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
      scanf("%i",&pay);
      if(pay==1){
        printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
        printf("Thank you for your payment.\n\n");
        goto Main_Menu;}
      if(pay==2){
        printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
        goto Main_Menu;}
      else{
        goto Pay3;}
    }
//female+A1    
    if((GDR==2 && choose==1) || (GDR==2 && choose==2) || (GDR==2 && choose==3)){
      printf("\nSorry. This block is not ready for occupancy.");
      goto Details;}
//female+B4
    if(GDR==2 && choose==4){
      B4:
      printf("\nHow many weeks of room booking?\n");
      scanf("%i",&B4_R_week);

Internet4:
      printf("\nDO you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&B4_Internet);
      if(B4_Internet==1){
        printf("How many weeks of subscription?\n");
        scanf("%i",&B4_I_week);
        goto Meal4;}
      if(B4_Internet==2){
        B4_Internet=0;}
      else{
        goto Internet4;}

Meal4:
      printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&B4_Meal);
      if(B4_Meal==1 ){
        printf("Sorry, this service is not available for subscription. Thank you.\n");
        goto Laundry4;}
      if(B4_Meal==2){
        goto Laundry4;}
      else{
        goto Meal4;}

Laundry4:
      printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&B4_Laundry);
      if(B4_Laundry==1){
        printf("How many weeks of subscription?\n");
        scanf("%i",&B4_L_week);
        goto Gym4;}
      if(B4_Laundry==2){
        B4_Laundry=0;}
      else{
        goto Laundry4;}

Gym4:
      printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
      scanf("%i",&B4_Gym);
      if(B4_Gym==1 ){
        printf("Sorry, this service is not available for subscription. Thank you\n");
        goto Info4;}
      if(B4_Gym==2){
        goto Info4;}
      else{
        goto Gym4;}

Info4:
      printf("\nPlease enter your name:");
      scanf("%s", B4_Name);
      printf("Please enter your Student ID:");
      scanf("%s",B4_SID);
      room_total= B4_room_rate*B4_R_week;
      L_total = Laundry_rate*B4_L_week;
      I_total = B4_Internet_rate*B4_I_week;
      B4_total = room_total + I_total+L_total;
    
    Pay4:
      printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",B4_room_rate, B4_R_week, room_total, Laundry_rate,B4_L_week,L_total,B4_Internet_rate,B4_I_week,I_total,B4_total);
      printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
      scanf("%i",&pay);
      if(pay==1){
        printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
        printf("Thank you for your payment.\n\n");
        goto Main_Menu;}
      if(pay==2){
        printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
        goto Main_Menu;}
      else{
        goto Pay4;}}

    if((GDR==1 && choose==5) || (GDR==2 && choose==5)){
      goto Main_Menu;}

    else{
      goto Main_Menu;}
  
  if(menu==2){
    printf("\n1 Check by type\n2 Check by gender\n3 Main Menu\nPlease enter your option:");
    scanf("%i",&check);
    if(check==1){
      Room_Type();
      scanf("%i",&choose);}
  }
}