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
|
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<conio.h>
typedef struct account
{
int account_ID;
char account_name[20];
int balance;
};
void print_records(account account_rec[10], int count)
{
printf("nn%10st%10st%10st","Acount Number","Account Name","Balance");
for(int i=0;i<count;i++)
{
printf("n%10dt%10st%10dt",account_rec[i].account_ID,account_rec[i].account_name,account_rec[i].balance);
}
}
void main()
{
///////////////////////////
///// Menu
///////////////////////////
char menu;
do
{
printf("nn==== Bank of USJ-R ===== n A - New Bank Account n D - Deposit n W - Withdraw n B - Balance Inquiry n Q - Quit n Select Option:");
menu=toupper(getche());
///////////////////////////
///// Account Creation
//////////////////////////
account accountrec[10];
int i=0,count=0;
char reply;
if(menu=='A')
{
do
{
system("cls");
printf("nnNew Bank Accountn");
fflush(stdin);
printf("nAccount ID: "); scanf("%d",&accountrec[i].account_ID);
fflush(stdin);
printf("Account Name: "); gets(accountrec[i].account_name);
printf("Balance : "); scanf("%d",&accountrec[i].balance);
count++;
i++;
printf("n Do You Wish to add another record?(Y/N) : ");
reply=toupper(getche());
}while (reply=='Y');
print_records(accountrec,count );
printf("n");
}
//This Part!!!!!
]////////////////////////
///// Deposit Balance
////////////////////////
int Iaccount,deposit;
if(menu=='D')
{
system("cls");
printf("nnDepositn");
printf("nAccount ID: "); scanf("%d",&Iaccount);
for(i=0;i<count;i++)
{
if(accountrec[i].account_ID == Iaccount)
{
fflush(stdin);
printf("Balance : "); scanf("%d",&deposit);
accountrec[i].balance+=deposit;
printf("Your New Balance %d",accountrec[i].balance);
}
else
{
printf("Account ID does not exist!");
}
}
fflush(stdin);
printf("Deposit : "); scanf("%d",&deposit);
accountrec[i].balance+=deposit;
printf("Your New Balance %d",accountrec[i].balance);
}
////////////////////////
///// Balance Inquire
////////////////////////
if(menu=='B')
{
print_records(accountrec,count );
}
/////////////////////
}while(menu!='Q');
}
|