help with my bank account program
i want write program for add new account, deposit money, withdraw money, transfer between accounts and display interest.
Code :
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?
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
Re: help with my bank account program
how can i use array list. can i write this?
Code :
ArrayList acc = new ArrayList();
acc.add(name);
acc.add(id);
acc.add(balance);
acc.add(date);
but isn't there only one array?
Re: help with my bank account program
could i write this way?
Code :
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.