Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help with my bank account program

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default help with my bank account program

    i want write program for add new account, deposit money, withdraw money, transfer between accounts and display interest.

     
     
    	public void createaccount(){
     
    		Scanner input = new Scanner(System.in);
    		System.out.println("Enter customer name:");
    		name = input.nextLine();
     
    		System.out.println("enter account id");
    		id = input.nextInt();
     
    		System.out.println("enter balance money");
    		balance = input.nextFloat();
     
    		System.out.println("enter creation date (dd/mm/yyyy) ");
    		date = input.nextLine();
    	}
     
    	public void deposit(){
     
    		Scanner input= new Scanner(System.in);
    		System.out.println("enter deposit money");
    		balance+= input.nextFloat();
    	}
     
    	public void withdraw(){
     
    		Scanner input= new Scanner(System.in);
    		System.out.println("enter withdraw money");
    		balance+= input.nextFloat();
     
    	}
     
    }

    i wrote this code.and think for transfer function(withdraw from one account and deposit to another account). but where do i store more than one account?
    Last edited by captain_turkiye; October 13th, 2011 at 08:33 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: help with my bank account program

    Use an array or an ArrayList

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/49814-basic-bank-account.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: help with my bank account program

    how can i use array list. can i write this?

     
    ArrayList acc = new ArrayList();
     
    acc.add(name);
    acc.add(id);
    acc.add(balance);
    acc.add(date);

    but isn't there only one array?

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: help with my bank account program

    could i write this way?

    account[] acc= new account[10];	
     
    	public void createaccount(int a){
     
     
    		Scanner input = new Scanner(System.in);
    		System.out.println("Enter customer name:");
    		acc[a].name = input.nextLine();
     
    		System.out.println("enter account id");
    		acc[a].id = input.nextInt();
     
    		System.out.println("enter balance money");
    		acc[a].balance= input.nextFloat();
     
    		System.out.println("enter creation date (dd/mm/yyyy) ");
    		acc[a].date = input.nextLine();
     
    	}

    i want use simple array.

Similar Threads

  1. Bank Account Program.
    By Punky0214 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 17th, 2010, 10:42 PM
  2. Please help - Bank account application
    By brandonssss in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 2nd, 2010, 03:10 PM
  3. Create a java small class for a bank account!!?
    By jon123 in forum Object Oriented Programming
    Replies: 2
    Last Post: March 24th, 2010, 11:00 AM
  4. Bank account GUI using swing
    By AlanM595 in forum AWT / Java Swing
    Replies: 5
    Last Post: April 2nd, 2009, 04:39 AM
  5. How to delete records from a Random-Access File?
    By keith in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: March 31st, 2009, 11:40 AM