4 Replies Latest reply: Jul 2, 2012 4:40 AM by gimbal2 RSS

    Help for write Bank application in Java

    919963
      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:
      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(" enter your deposit money :");
      amount=clapton.nextFloat();
      balance + = amount;
      }
      else if (x==2) {
      float amount;
      System.out.println(" enter your Withdraw money :");
      amount=clapton.nextFloat();
      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");
      }
      }

      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?