@SitiNurAishahNu/

GrotesqueBurlywoodGnuassembler

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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct bookings {
	char carModel[60];
	char carID[15];
	char customerF[60];
	char customerL[60];
	char customerID[15];
	char phoneNo[11];
	char seater[50];
	int day;
	int month;
	int year;
	int duration;
	int tprice;
	int price;
	struct node* next;
} *head;


void addNew() {
	int numSeater, numModel1, numModel2, numModel3;
	char custID[15];
	struct bookings *newNode = (struct bookings*) malloc(sizeof(struct bookings));
	printf("Insert how many seater: \n[1] 4 seater\n[2] 8 seater\n[3] 12 seater");
	printf("\nChoose [1]/[2]/[3] : ");
	scanf_s("%d", &numSeater);
	if (numSeater > 3) {
		do {
			printf("Invalid option.\nChoose: \n[1] 5 seater\n[2] 8 seater");
			printf("\nChoose [1]/[2]/[3] : ");
			scanf_s("%d", &numSeater);
		} while (numSeater > 3);
	}
	switch (numSeater) {
	case 1: strcpy_s(newNode->seater, sizeof(newNode->seater), "5 seater");
		printf("Choose car model: \n[11]Proton Saga (RM50/day)\n[22] Perodua Myvi (RM40/day)\n[33] Honda CRV (RM80/day)\n[44] Toyota Hilux (RM100)");
		printf("\nChoose [1]/[2]/[3]/[4] : ");
		scanf_s("%d", &numModel1);
		switch (numModel1) {
		case 11: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Proton Saga");
			
			break;
		case 22: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Perodua Myvi");
			break;
		case 33: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Honda CRV");
			break;
		case 44: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Toyota Hilux");
			break;
		default: main();
			break;
		}
		break;

	case 2: strcpy_s(newNode->seater, sizeof(newNode->seater), "8 seater");
		printf("Choose car model: \n[1] Toyota Vellfire (RM180/day)\n[2] Toyota Alphard (RM150/day)\n[3] Ford Expedition (RM160/day)\n[4] Honda Pilot (RM120)");
		printf("\nChoose [1]/[2]/[3]/[4] : ");
		scanf_s("%d", &numModel2);
		switch (numModel2) {
		case 1: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Toyota Vellfire");
			break;
		case 2: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Toyota Alphard");
			break;
		case 3: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Ford Expedition");
			break;
		case 4: strcpy_s(newNode->carModel, sizeof(newNode->carModel), "Honda Pilot");
			break;
		default: main();
			break;
		}
		break;