-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcproject.c
136 lines (136 loc) · 4.94 KB
/
cproject.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
#include<stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
typedef struct acc_type
{ char bank_name[20];
char bank_branch[20];
char acc_holder_name[100];
int acc_number;
char acc_holder_address[100];
float available_balance;
}acc;
int num_acc;
int acc_num =787899;
void Create_new_account();
void Cash_Deposit();
void Cash_withdrawl();
void Account_information();
void display_options();
int i=0;
struct acc_type list[100];
int main(){
char option;
char myp[50] = "Ritam Bhattacharya_B_21";
int j=0;
printf("\n***** Welcome to Bank Application *****\n");
printf("\nThis demo program is brought you by %s\n",myp);
while (j>=0){
printf("Choose any option given below:->");
display_options();
printf("Please enter any (1/2/3/4/5/6) ");
printf("to continue : ");
option = getch();
printf("%c \n", option);
switch(option)
{ case '1': Create_new_account();
break;
case '2': Cash_Deposit();
break;
case '3': Cash_withdrawl();
break;
case '4': Account_information();
break;
case '5': return 0;
case '6': system("cls");
break;
default : system("cls");
printf("Please enter one of the options");
printf("(1/2/3/4/5/6) to continue \n ");
break;
}j++;
}
return 0;
}void display_options(){
printf("\n1. Create new account \n");
printf("2. Cash Deposit \n");
printf("3. Cash withdrawl \n");
printf("4. Account information \n");
printf("5. Log out \n");
printf("6. Clear the screen and display available ");
printf("options \n\n");
}void Create_new_account(){
char acc_holder_name[100];
char acc_holder_address[100];
float available_balance = 0;
fflush(stdin);
strcpy(list[i].bank_name,"Finova");
strcpy(list[i].bank_branch,"sector-5");
printf("\nEnter the account holder name:");
fgets(acc_holder_name,100,stdin);
list[i].acc_number=acc_num;
printf("\nEnter the account holder address:");
fgets(acc_holder_address,100,stdin);
strcpy(list[i].acc_holder_name,acc_holder_name);
strcpy(list[i].acc_holder_address,acc_holder_address);
list[i].available_balance=available_balance;
printf("\nAccount has been created successfully \n\n");
printf("Bank name : %s \n" , list[i].bank_name);
printf("Bank branch : %s \n" , list[i].bank_branch);
printf("Account holder name :");
puts(acc_holder_name);
printf("Account number : %d \n" , list[i].acc_number);
printf("\nAccount holder address :");
puts(acc_holder_address);
printf("\nAvailable balance : %f \n" , list[i].available_balance);
i=i+1;
acc_num=acc_num+1;
}void Account_information(){
int n,i;
printf("Enter the bank account no:");
scanf("%d",&n);
for(i=0;i<100;i++){
if(list[i].acc_number==n){
printf("\n Bank name: %s \n" ,list[i].bank_name);
printf("Bank branch: %s \n" , list[i].bank_branch);
printf("Account holder name: %s \n",list[i].acc_holder_name);
printf("Account number: %d\n",list[i].acc_number);
printf("Account holder address: %s \n" ,list[i].acc_holder_address);
printf("Available balance: %f \n\n",list[i].available_balance);
return;
}
}printf("Account not found!\n");
}void Cash_Deposit(){
int acc_no,i;
float add_money;
printf("Enter the bank account no you want to deposit money:");
scanf("%d",&acc_no);
printf("\nEnter money you want to deposit : ");
scanf("%f",&add_money);
for(i=0;i<100;i++){
if(list[i].acc_number==acc_no){
printf("\nThe Last balance for account %d is %f \n", acc_no, list[i].available_balance);
list[i].available_balance=list[i].available_balance+add_money;
printf("\nThe New balance for account %d is %f \n",acc_no,list[i].available_balance);
return;
}
}printf("Invalid account no ");
}void Cash_withdrawl(){
int acc_no,i=0;
float withdraw_money;
printf("Enter the bank account no you want to withdraw money:");
scanf("%d",&acc_no);
printf("\nEnter money you want to withdraw : ");
scanf("%f",&withdraw_money);
for(i=0;i<100;i++){
if(list[i].acc_number==acc_no){
printf("\nThe Last balance for account %d is %f \n", acc_no, list[i].available_balance);
if(list[i].available_balance>=withdraw_money){
list[i].available_balance=list[i].available_balance-withdraw_money;
printf("\nThe New balance for account %d is %f \n", acc_no, list[i].available_balance);
}else{
printf("Not enough balance !!");
}return;
}
}printf("Account not found!\n");
}