-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.c
More file actions
145 lines (140 loc) · 4.66 KB
/
Copy pathATM.c
File metadata and controls
145 lines (140 loc) · 4.66 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
// Progarm For ATM
/*It's an atm program that is used to make easy transcations, can check balance, withdraw money easily, transfer amounts as well. */
#include <stdio.h>
#include <math.h>
#include <conio.h>
#define Max_Lenght 100
int main()
{
int cnic,amount, tremaining,options,withdraw,remaining;
int balance = 100000;
int dpin = 1973, upin = 0;
char feedback;
int counter,foptions = 0;
printf("-----------------Welcome To UBL ATM------------------\n");
printf("-------------------------------------------------\n");
printf("Enter Your CNIC Number : \n");
scanf("%i", &cnic);
printf("Enter Your 4 digit-pin: \n");
scanf("%i", &upin);
// making the loop in start to consice the program
if (upin != dpin)
{
int attempts = 1;
while (upin != dpin)
{
printf("Ivalid pin\nRe-Enter Pin: ");
scanf("%d", &upin);
attempts++; //making counter to limit the attempts.
if (attempts == 3 && upin != dpin) //making both conditions true then breaking the code.
{
printf("Your account has been locked\nVisit the branch");
break;
}
// intializing a new variable to limit the re try options.Making a counter
}
}
if (upin == dpin)
{
printf("[1]Fast Cash\n[2]Current Balnce\n[3]Deposit Cash\n[4]Transfer amount\n[5]Exit\n");
scanf("%d", &options);
if (options == 1)
{
printf("Enter your amount need to be withdraw\n");
scanf("%d", &withdraw); // Displays your withdrawn money
if (balance >= withdraw)
{
printf("Your withdrawn amount is %d\n", withdraw);
remaining = balance - withdraw;
printf("Your remaining balance is %d\nThank you for using UBL\n", remaining);
}
else if (balance < withdraw)
{
printf("Insufficent balance\n");
}
}
else if (options == 2)
{
printf("Your current balance is %i\nThank you for using UBL\n", balance);
}
else if (options == 3)
{
int deposit;
printf("Enter your deposit amount\n");
scanf("%i", &deposit);
deposit = balance + deposit;
printf("Your new amount is %i\nThank you For choosing UBL\n", deposit);
}
else if (options == 4)
{
int accountnum;
printf("Enter your account number\n");
scanf("%d", &accountnum);
printf("Enter amount need to be transferred\n");
scanf("%i", &amount);
if (amount <= balance)
{
tremaining = balance - amount;
printf("Your transferred amount is %d \nYour remaining balance is : %d", amount, tremaining);
}
else
{
printf("Insufficent balance\nTry again later\n");
}
}
else if (options == 5)
{
printf("Thank you for choosing United Bank Limited\nVisit again\n");
}
else{
printf("Invalid input\n");
}
printf("Give your feedback\nSelect Y for Yes\n N for No\n");
// Consume the leftover newline character from previous input
while (getchar() != '\n');//The buffer holds any characters entered by the user until they are consumed by the program
scanf("%c", &feedback);
switch (feedback)
{
case 'Y':
{
int foptions;
printf("[1]. Excellent\n[2]. Good\n[3]. Average\n[4]. Laggy\n");
scanf("%d", &foptions);
if (foptions >= 1 && foptions <= 4)
{
printf("Thank you for your kind feedback\nVisit again\n");
}
else
{
printf("Invalid choice\nThank you\n");
}
break;
}
case 'y':
{
int foptions;
printf("[1]. Excellent\n[2]. Good\n[3]. Average\n[4]. Laggy\n");
scanf("%d", &foptions);
if (foptions >= 1 && foptions <= 4)
{
printf("Thank you for your kind feedback\nVisit again\n");
}
else
{
printf("Invalid choice\nThank you\n");
}
break;
}
case 'N':
printf("Thank you\nHave a nice day\n");
break;
case 'n':
printf("Thank you\nHave a nice day\n");
break;
default:
printf("Invalid input\n");
break;
}
}
return 0;
}