-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
114 lines (112 loc) · 2.54 KB
/
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
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int list();
void transfer();
void deposit();
void last();
void withdraw();
void checkdetail();
int total_amount = 2500, Amount, Amo, Tr, total_deposit = 0, total_withdraw = 0;
int totalTr = 0;
int Acc;
char a[50];
void main()
{
printf("Enter your name:\n ");
gets(a);
printf("Enter your account number:\n ");
scanf("%d", &Acc);
while (1)
{
switch (list())
{
case 1:
deposite();
total_deposit += Amount;
break;
case 2:
withdraw();
if (Amo <= total_amount)
total_withdraw += Amo;
break;
case 3:
transfer();
if (Tr <= total_amount)
totalTr += Tr;
break;
case 4:
checkdetail();
break;
case 5:
last();
getch();
exit(0);
default:
printf("\n Invalid ID choice");
} //end of switch
getch();
} //end of while
}
int list()
{
int ch;
printf("\n 1. Diposit amount");
printf("\n 2. Withdraw amount");
printf("\n 3. Transfer amount");
printf("\n 4. Check details");
printf("\n 5. Exit");
printf("\n Enter you choice: ");
scanf("%d", &ch);
return (ch);
}
void deposit()
{
printf("\n Enter the amount you want to deposit: ");
scanf("%d", &Amount);
total_amount += Amount;
}
void withdraw()
{
printf("\n Enter the amount you want to withdraw: ");
scanf("%d", &Amo);
if (Amo <= total_amount)
{
total_amount = Amo;
}
else
{
printf("\n Less amount withdraw is not possible: ");
}
}
void transfer()
{
printf("\n Enter the amount you want to transfer: ");
scanf("%d", &Tr);
if (Tr <= total_amount)
{
total_amount -= Tr;
}
else
{
printf("\n Less amount is not possible: ");
}
}
void checkdetail()
{
printf("\n Total amount= %d", total_amount);
printf("\n Total deposite amount= %d", total_deposit);
printf("\n Total withdraw amount= %d", total_withdraw);
printf("\n Total transfered amount= %d", totalTr);
}
void last()
{
printf("\n*******\n");
printf("\n Your name= %s", a);
printf("\n Account number= %d", Acc);
printf("\n Total amount= %d", total_amount);
printf("\n Total deposited amount= %d", total_deposit);
printf("\n Total withdraw amount= %d", total_withdraw);
printf("\n Total transfered amount= %d", totalTr);
printf("\n*******\n");
}