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

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




Banking System

 
Reply to this topicStart new topic

Banking System

Luma
19 May, 2008 - 12:39 PM
Post #1

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 2

CODE


I created this banking system it will ask the user to enter the details for 3 customers & then will ask the user 2 choose one of these choices deposit or withdraw & the user should choose one of the customers 2 implement one of the choices withdraw or deposit.  My problem is when i choose withdraw or deposit it's always  implement it on the [color=#FF0000]3rd customer [/color] so what 2 do???


#[indent]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  
{  
float withdraw;  
float 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;  
  
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;  
     int x;
   for(x=0;x<2;x++)  
    {  
        printf("\n these are your choices\n");  
        printf("how much you want to withdraw\n" );  
        printf("how much u want to deposit\n");  
  
        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", &opr[0].withdraw);  
                cust.balance=cust.balance-opr[0].withdraw;  
                accbalance-=opr[0].withdraw;  
                printf("%d", cust.balance);  
                break;  
            case 2:  
                printf("\n\n deposit\n");  
                printf("how much you wana deposit\n\n");  
                scanf("%f", &opr[1].deposit);
                cust.balance=cust.balance+opr[1].deposit;
                accbalance+=opr[1].deposit;  
                printf("%d", cust.balance);  
                break;  
            default:  
                printf("\n\n not correct\n");  
        }  
    
        }
    return(0);
      }



        
  

User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Banking System
19 May, 2008 - 12:43 PM
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
I'm sure I saw this code earlier...
QUOTE(Luma's Code)
[indent]
You remembered to indent it this time laugh.gif

I'm not too sure about your code to be honest... it's difficult to read and the output is messy.

What's with all the loops? I got really bored testing it (so much input!) , and I didn't even see the problem when I got to the end.

This post has been edited by gabehabe: 19 May, 2008 - 12:47 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:04AM

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