Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 135,912 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,550 people online right now. Registration is fast and FREE... Join Now!




creating banking system in C language

 
Reply to this topicStart new topic

creating banking system in C language, i want 2 create menu consist of withdraw & deposit & user will

Luma
19 May, 2008 - 03:15 AM
Post #1

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 2

[font=Comic Sans Ms][size=3]
CODE

#include<stdio.h>

int accbalance;


void main()


{


int empid;
printf("Welcome to the banking system\n");


printf("Enter employee Id\n");

scanf("%d",&empid);

if((empid==100) || (empid==200) || (empid==300))
printf("Welcome %d to the banking system",empid);
else
printf("the ID you enetered not correct\n");




struct customer

{

int cno;
char name[10];
char city [6];
int tel [10];
  int ano;
int balance;
}cust;

struct operation
{
int withdraw;
int deposit;
}opr[2];

int i, int x;




for(i=0;i<3;i++)


{


printf("\nEnter customer details\n");

printf("\nEnter customer ID\n");

scanf("%d",&cust.cno);


getchar();

printf("Enter customer name\n");
gets(cust.name);

printf("\n\nEnter city\n");

gets(cust.city);

printf("\n\nEnter customer Telephone No.\n");

scanf("%d", &cust.tel);



printf("\n\nEnter account details\n");

printf("\n\nEnter account ID\n");

scanf("%d",&cust.ano);


printf("\n\n Enter balance\n");

scanf("%d", &cust.balance);
}


printf("\n\n Enter customer ID\n");

scanf("%d",&cust.cno);



int choice;

  for(x=0;x<2;x++)
      printf("\n these are your choices\n");
      

      printf("%d%d",x+1, opr[x].withdraw );
      
    printf("%d%d",x+1, opr[x].deposit);
    




printf("\n\n Enter your choice\n");

scanf("%d", &choice);


float with, dep;


switch (choice)

{

case 1:

printf("\n\n withdraw\n");

printf("\n\n how much u want to withdrwa\n");

scanf("%f", &with);

cust.balance=cust.balance-with;

accbalance-=with;

printf("%d", cust.balance);

break;

case 2:

printf("\n\n deposit\n");

printf("how much you wana deposit\n\n");

scanf("%f", &dep);

cust.balance=cust.balance+dep;

accbalance+=dep;

printf("%d", cust.balance);

break;

default:

printf("\n\n not correct\n");

break;

}


User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Creating Banking System In C Language
19 May, 2008 - 03:16 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,514



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
What problem are you having?

EDIT: Don't you indent your code? It makes it much more readable. Just a tip for the future smile.gif

This post has been edited by gabehabe: 19 May, 2008 - 03:17 AM
User is offlineProfile CardPM
+Quote Post

KYA
RE: Creating Banking System In C Language
19 May, 2008 - 04:04 AM
Post #3

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 4,730



Thanked: 89 times
Dream Kudos: 1200
My Contributions
No indention also makes if and else statements not work
User is online!Profile CardPM
+Quote Post

gabehabe
RE: Creating Banking System In C Language
19 May, 2008 - 04:35 AM
Post #4

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,514



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Just because I'm a nice guy (actually, it's because I was bored) here is your code, INDENTED and it now compiles. I haven't tested it, but try identifying your errors next time. I don't know if it's what you want, but to be honest, you won't get what you want unless you tell us and show your efforts in the problem area.

cpp
/** ERRORS:
main should return int, not void
INDENT YOUR CODE!
structs go outside of main
missing } at end of main
*/

#include<stdio.h>

int accbalance;

struct customer
{
int cno;
char name[10];
char city [6];
int tel [10];
int ano;
int balance;
}cust;

struct operation
{
int withdraw;
int deposit;
}opr[2];

int main()
{
int empid;
printf("Welcome to the banking system\n");
printf("Enter employee Id\n");
scanf("%d",&empid);

if((empid==100) || (empid==200) || (empid==300))
printf("Welcome %d to the banking system",empid);
else
printf("the ID you enetered not correct\n");

int i, x;

for(i=0;i<3;i++)
{
printf("\nEnter customer details\n");
printf("\nEnter customer ID\n");
scanf("%d",&cust.cno);
getchar();
printf("Enter customer name\n");
gets(cust.name);
printf("\n\nEnter city\n");
gets(cust.city);
printf("\n\nEnter customer Telephone No.\n");
scanf("%d", &cust.tel);
printf("\n\nEnter account details\n");
printf("\n\nEnter account ID\n");
scanf("%d",&cust.ano);
printf("\n\n Enter balance\n");
scanf("%d", &cust.balance);
}

printf("\n\n Enter customer ID\n");
scanf("%d",&cust.cno);
int choice;

for(x=0;x<2;x++)
{
printf("\n these are your choices\n");
printf("%d%d",x+1, opr[x].withdraw );
printf("%d%d",x+1, opr[x].deposit);

printf("\n\n Enter your choice\n");
scanf("%d", &choice);
float with, dep;

switch (choice)
{
case 1:
printf("\n\n withdraw\n");
printf("\n\n how much u want to withdrwa\n");
scanf("%f", &with);
cust.balance=cust.balance-with;
accbalance-=with;
printf("%d", cust.balance);
break;
case 2:
printf("\n\n deposit\n");
printf("how much you wana deposit\n\n");
scanf("%f", &dep);
cust.balance=cust.balance+dep;
accbalance+=dep;
printf("%d", cust.balance);
break;
default:
printf("\n\n not correct\n");
}
}
}


This post has been edited by gabehabe: 19 May, 2008 - 04:35 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 07:47AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month