1,105,214 Community Members

atm bank system in turbo c

Member Avatar
nimuns
Newbie Poster
2 posts since May 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
1
 

i have here 2 program the first one #include<stdio.h>

#include<conio.h>
#include<stdlib.h>
#include<process.h>

struct record{
char acc_name[6];
int pin;
float bal;
};
void main()
{
FILE *fp;

struct record b;
clrscr();

if((fp=open("accounts.dat","wt"))==0)
{
printf("Error");
exit(1);
}

printf("Enter account name:");
gets(b.acc_name);
printf("Enter account pin:");
scanf("%d",&b.pin);
printf("Enter balance:");
scanf("%f",&b.bal);

fprintf(fp,"%s %d %.2f",b.acc_name,b.pin,b.bal);
fclose(fp);
}

it lets user enter data and eventuallly store them in .dat file. this is a file handling in binary mode.
and the other one is this

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>

void main()
{
FILE *fp;
char key,opt,ex,acc_name,x,y,z;
float amt_dep,amt_with,bal;
int pin;

fp=fopen("accounts.dat","r");
if(fp==NULL)
{
printf("Error");
exit(1);
}

clrscr();
printf("Account name:");
scanf("%s",&acc_name);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{b.acc_name=x;
if(acc_name=x)
{
printf("account name accepted!");
}
else{printf("invalid account!");}
}}
printf("Enter PIN:");
scanf("%d",&pin);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{printf("access granted!");
goto menu_dep;
}
else{
printf("Access denied!");}

menu:
{
printf("[1] balance inquiry");
printf("[2] deposit");
printf("[3] withdraw");

opt=getche();
}
switch(opt);
{
case '1':

{
clrscr();
printf("balance inquiry");
while(&fread(&b,sizeof(record),1,fp)!=NULL)
printf("your current balance is:%.2f",b.bal);
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}

clrscr();
{
case '2':

clrscr();
printf("amount to deposit:P");
scanf("%f",&amt_dep);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{
b.bal=z;
z=amt_dep+z;
printf("your balance now is P%.2f",z);}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
case'3':
{clrscr("amount to withdraw: P");
scanf("%f"&amt_with);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
z=z-amt_with;
if(amt_with>z)
{
printf("Isuficient balance!");
}
else{printf("thank you! ");}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
fclose(fp);
}

it is the atm program, it lets user input an account name if the account name did not match in the data yuo have previously typed in the first program it displays invalid account. my problem now is how can i match the data i input in the second program in the data stored in the first program. pls help me. i need this on wednesday.
and we only use the printf scanf version not the cin and cout.thank you!!

Member Avatar
dkalita
Posting Pro in Training
402 posts since Sep 2009
Reputation Points: 110 [?]
Q&As Helped to Solve: 61 [?]
Skill Endorsements: 0 [?]
 
0
 

read on string handling.
U are declaring a char to store a string. U are using

if(acc_name=x){}

whereas your intention is to compare string. The above statement is an assignment and the value will be true if the assignment was successful.
Read how to read and compare strings.

Member Avatar
hOnEyOj
Newbie Poster
1 post since Mar 2010
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-3
 

i have here 2 program the first one #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>

struct record{
char acc_name[6];
int pin;
float bal;
};
void main()
{
FILE *fp;

struct record b;
clrscr();

if((fp=open("accounts.dat","wt"))==0)
{
printf("Error");
exit(1);
}

printf("Enter account name:");
gets(b.acc_name);
printf("Enter account pin:");
scanf("%d",&b.pin);
printf("Enter balance:");
scanf("%f",&b.bal);

fprintf(fp,"%s %d %.2f",b.acc_name,b.pin,b.bal);
fclose(fp);
}

it lets user enter data and eventuallly store them in .dat file. this is a file handling in binary mode.
and the other one is this

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>

void main()
{
FILE *fp;
char key,opt,ex,acc_name,x,y,z;
float amt_dep,amt_with,bal;
int pin;

fp=fopen("accounts.dat","r");
if(fp==NULL)
{
printf("Error");
exit(1);
}

clrscr();
printf("Account name:");
scanf("%s",&acc_name);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{b.acc_name=x;
if(acc_name=x)
{
printf("account name accepted!");
}
else{printf("invalid account!");}
}}
printf("Enter PIN:");
scanf("%d",&pin);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{printf("access granted!");
goto menu_dep;
}
else{
printf("Access denied!");}

menu:
{
printf("[1] balance inquiry");
printf("[2] deposit");
printf("[3] withdraw");

opt=getche();
}
switch(opt);
{
case '1':

{
clrscr();
printf("balance inquiry");
while(&fread(&b,sizeof(record),1,fp)!=NULL)
printf("your current balance is:%.2f",b.bal);
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}

clrscr();
{
case '2':

clrscr();
printf("amount to deposit:P");
scanf("%f",&amt_dep);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
{
b.bal=z;
z=amt_dep+z;
printf("your balance now is P%.2f",z);}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
case'3':
{clrscr("amount to withdraw: P");
scanf("%f"&amt_with);
while(&fread(&b,sizeof(record),1,fp)!=NULL)
z=z-amt_with;
if(amt_with>z)
{
printf("Isuficient balance!");
}
else{printf("thank you! ");}
printf("another transaction?([y]/n)");
ch=getch();
if(ch=='Y'||ch=='y')
{
goto menu;
}
clrscr();
}
fclose(fp);
}

it is the atm program, it lets user input an account name if the account name did not match in the data yuo have previously typed in the first program it displays invalid account. my problem now is how can i match the data i input in the second program in the data stored in the first program. pls help me. i need this on wednesday.
and we only use the printf scanf version not the cin and cout.thank you!!

may i know the output of this ATM program ?? .. our final exam for tom. is to make a Simple ATM program using Turbo C data base. asap ! tNx!

Member Avatar
Nick Evan
Industrious Poster
4,827 posts since Oct 2006
Reputation Points: 4,005 [?]
Q&As Helped to Solve: 560 [?]
Skill Endorsements: 30 [?]
Team Colleague
Featured
 
1
 

may i know the output of this ATM program ?? .. our final exam for tom. is to make a Simple ATM program using Turbo C data base. asap ! tNx!

So you decided to cheat your way trough class by googling "ATM C++" and you ended up here. And now you're even too lazy to compile the code and find out what the output is? How on earth do you think you're going to pass this class with that kind of attitude?

Next time start here and go here.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article