Results 1 to 5 of 5
  1. #1
    clapton is offline Member
    Join Date
    Feb 2012
    Posts
    5
    Rep Power
    0

    Default Help for write Bank application in Java

    Hi.
    I'm a student and I need write a programe bank application in java .
    I must write a program that the customer could withdraw and deposit from his account.I wrote this program.
    but I need to use several classes for this program. for exemple:
    BankAccount which has an instance variable amount
    and has methods:
    withDraw which takes a parameter -> amountToWithDraw
    deposit -> amountToAdd
    checkBalance -> which takes no parameters, but which returns the value in the instance variable amount.
    but i dont know how use of several classes.
    you can help me?


    Java Code:
    import java.util.Scanner;
     
     public class BankAccount {
     public static void main(String[] args) {
          
         Scanner clapton=new Scanner(System.in);
         int x;
         float balance = 0;
         boolean quit=false;
           do {
             System.out.println("1. Deposit money");
     
             System.out.println("2. Withdraw money");
      
             System.out.println("3. Check balance");
       
             System.out.print(" 0 to quit: ");
      
             System.out.println("enter your choice :");
        
          x=clapton.nextInt();
                      if (x==1) {
       
             float amount;
             System.out.println(" Amount to deposit :");
             amount=clapton.nextFloat();  
             if (amount>=0) {              
          balance += amount;                  
    }                   
     else {                  
       System.out.println("system can't reply your request");   
      }
     
    }
    else if (x==2) {   
         float amount;    
        System.out.println(" Amount to withdraw :");   
         amount =clapton.nextFloat();         
                if (amount<=0 || amount > balance) { 
                     System.out.println("system can't reply your request ");
                                  
       }          
                       else {
                           balance -= amount; 
       } 
    }
    else if (x==3) {     
       System.out.println("your balance :" + balance );
    }
    else if (x==0) {     
       quit=true;
    }
    else {
            System.out.println("wrong choice");
      }
    }
      while (!quit);
            System.out.println("bye");
       }
    }
    Last edited by Norm; 02-26-2012 at 05:30 PM. Reason: changed quote to code tags

  2. #2
    santa's Avatar
    santa is offline Senior Member
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    208
    Rep Power
    5

    Default Re: Help for write Bank application in Java

    Last edited by santa; 02-26-2012 at 03:21 PM.

  3. #3
    clapton is offline Member
    Join Date
    Feb 2012
    Posts
    5
    Rep Power
    0

    Default Re: Help for write Bank application in Java

    you can say how I use objects for this program?

  4. #4
    santa's Avatar
    santa is offline Senior Member
    Join Date
    Nov 2009
    Location
    Sweden
    Posts
    208
    Rep Power
    5

    Default Re: Help for write Bank application in Java

    Each account can be viewed as an Object ... check the link i provided

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: Help for write Bank application in Java

    Object oriented programming starts with realizing that you don't just have to specify what needs to be done, but also who (or what again) needs to do it. In your program everything is done in a main( ... ) method.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. help java bank....
    By natsuki in forum Introductions
    Replies: 2
    Last Post: 07-25-2011, 03:36 AM
  2. java bank account problem
    By awil121 in forum New To Java
    Replies: 1
    Last Post: 10-13-2010, 10:47 PM
  3. Create a java class for a bank account!!?
    By singh345 in forum New To Java
    Replies: 1
    Last Post: 03-17-2010, 04:26 PM
  4. Java Question Bank
    By mgm2010 in forum New To Java
    Replies: 2
    Last Post: 07-31-2009, 06:45 PM
  5. java program for updating bank details
    By java__beginner in forum New To Java
    Replies: 5
    Last Post: 03-12-2009, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •