-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopping_system.c
195 lines (161 loc) · 7.07 KB
/
shopping_system.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
#include <stdio.h>
#include <string.h>
int main() {
static int totalCost;
float TOTAL = 0;
int i, j, choice, c = 1, a[9], cost[9], pin = 0, exit_choice = 1;
char str[100];
char items[4][100] = {
"WHEAT 1 KG",
"RICE 1 KG",
"SUGAR 1 KG",
"CLARIFIED BUTTER 1 KG"
};
for (i = 0; i < 9; i++)
a[i] = 0;
printf("***************PROGRAMMER'S BLOCK***************\n");
printf("Made by Navika Agarwal\n");
printf("Just implementation of the first programming language which I learned in my college in my 1st Year!\n");
printf("Please Enter Your Name\n");
fgets(str, sizeof(str), stdin);
str[strcspn(str, "\n")] = '\0';
printf("Hello %s, Welcome to our Online Shopping.\n", str);
printf("\n****************SECURITY CODE TO ACCESS BANKING SERVICE IS 1520****************\n");
do {
printf("Enter\n1 - SHOPPING STORE\n2 - BANKING OPTION\n3 - HELP OPTION\n - CLICK ANY OTHER KEY TO EXIT\n");
scanf("%d", &choice);
switch (choice) {
case 1: {
int SHOPPINGCHOICE;
printf("Enter\n1 - WHEAT-Rs.20\n2 - RICE - Rs.100\n3 - SUGAR - Rs.40\n4 - CLARIFIED BUTTER - Rs.500\n5-PRESS ANY OTHER KEY TO EXIT\n");
printf("All prices are of each commodity per kilogram\n");
scanf("%d", &SHOPPINGCHOICE);
cost[0] = 20;
cost[1] = 100;
cost[2] = 40;
cost[3] = 500;
switch (SHOPPINGCHOICE) {
case 1: {
int num;
printf("You chose WHEAT COSTING Rs.20 RUPEES PER KG. ARE you sure to buy. If 'Yes' Enter 1 else any number\n");
scanf("%d", &num);
if (num == 1) {
a[0]++;
totalCost += 20;
TOTAL = totalCost + (0.13 * totalCost);
}
printf("Your Cost in Cart is %f\n", TOTAL);
break;
}
case 2: {
int num;
printf("You chose RICE COSTING Rs.100 PER KG. Are you sure to buy. If 'Yes' Enter 1 else any number\n");
scanf("%d", &num);
if (num == 1) {
a[1]++;
totalCost += 100;
TOTAL = totalCost + (0.13 * totalCost);
}
printf("Your Cost in Cart is %f\n", TOTAL);
break;
}
case 3: {
int num;
printf("You chose SUGAR COSTING Rs.40 PER KG. Are you sure to buy. If 'Yes' Enter 1 else any number\n");
scanf("%d", &num);
if (num == 1) {
a[2]++;
totalCost += 40;
TOTAL = totalCost + (0.13 * totalCost);
}
printf("Your Cost in Cart is %f\n", TOTAL);
break;
}
case 4: {
int num;
printf("You chose CLARIFIED BUTTER COSTING Rs.500 PER KG. Are you sure to buy. If 'Yes' Enter 1 else any number\n");
scanf("%d", &num);
if (num == 1) {
a[3]++;
totalCost += 500;
TOTAL = totalCost + (0.13 * totalCost);
}
TOTAL = totalCost + (0.13 * totalCost);
printf("Your Cost in Cart is %f\n", TOTAL);
break;
}
default: {
printf("Exit from SHOPPING STORE\n");
break;
}
}
break;
}
case 2: {
float amount = 1000, deposit;
int k;
char transaction = 'y';
printf("\n***************SECURITY CODE TO ACCESS BANKING SERVICE IS 1520***************\n");
while (pin != 1520) {
printf("ENTER YOUR SECRET PIN NUMBER:");
scanf("%d", &pin);
if (pin != 1520)
printf("PLEASE ENTER VALID PASSWORD\n");
}
do {
printf("***************Welcome to Banking System****************\n");
printf("1. Check Balance\n");
printf("2. Deposit Cash\n");
printf("3. Payment\n");
printf("4. Quit\n");
printf("*****?*****?*****\n\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("\n YOUR BALANCE IN Rs : %f ", amount);
break;
case 2:
printf("\n ENTER THE AMOUNT TO DEPOSIT");
scanf("%f", &deposit);
amount = amount + deposit;
printf("YOUR BALANCE IS %f", amount);
break;
case 3:
if (TOTAL > amount) {
printf("less balance increase the deposit");
break;
} else {
amount = amount - TOTAL;
printf("YOUR PAYMENT IS DONE AND BALANCE AMOUNT IN YOUR ACCOUNT IS %f", amount);
break;
}
case 4:
printf("\n THANK U USING BANKING SERVICE\n");
break;
default:
printf("\n INVALID CHOICE");
}
printf("\n\n\n DO U WISH TO HAVE ANOTHER TRANSACTION?(y/n): \n");
fflush(stdin);
scanf(" %c", &transaction);
if (transaction == 'n' || transaction == 'N')
k = 1;
} while (!k);
printf("\n\n THANKS FOR USING BANKING SERVICES\n\n");
break;
}
case 3:
printf("\n***************HELP CENTER***************\n");
printf("FOLLOW THE FOLLOWING STEP TO OPERATE");
printf("\n\n1-enter your name\n2-choose from the given option to enter the required part\n3-follow the step inside the particular specific");
break;
default: {
printf("Exit from program\n");
exit_choice = 0;
break;
}
}
} while (exit_choice == 1);
return 0;
}