import java.io.*;
import java.util.*;
class Account{
String accno;
String names;
String times;
String idno;
double deposit;
BufferedReader objBR=new BufferedReader(new InputStreamReader(System.in));
Account(){};
Account(String accno,String names,String times,String idno,double deposit){
this.accno=accno;
this.names=names;
this.times=times;
this.idno=idno;
this.deposit=deposit;
}
public void Deposit(Account account)throws IOException{
try{
System.out.println("Please input the amount of money you want to deposit!");
String strFirst1=objBR.readLine();
double damount=Double.parseDouble(strFirst1);
account.deposit=account.deposit+damount;}catch(IOException e){
System.out.println("Error!");
}
System.out.println("The amount of your money is:"+account.deposit+"now!");
}
public void Withdraw(Account account)throws IOException{
try{
System.out.println("Please input the amount of money you want to withdraw!");
String strFirst2=objBR.readLine();
double wamount=Double.parseDouble(strFirst2);
account.deposit=account.deposit-wamount;}catch(IOException e){
System.out.println("Error!");
}
System.out.println("The amount of your money is:"+account.deposit+"now!");
}
}
public class AccountOper
{
AccountOper(){};
static void Choose(){
System.out.println("Please choose the operation which you want!");
System.out.println("1.Deposit!");
System.out.println("2.Withdraw!");
System.out.println("3.Scan the record!");
System.out.println("4.Exit!");
}
public static void main(String args[])throws IOException{
Scanner scan=new Scanner(System.in);
Account account[]=new Account[10];
for(int i=0;i<10;i++){
System.out.println("Please input the information in order!");
System.out.print("The account number is:");
String accno=scan.next();
System.out.println(accno);
System.out.print("The name is:");
String names=scan.next();
System.out.println(names);
System.out.print("The time of account beginning is:");
String times=scan.next();
System.out.println(times);
System.out.print("The number of ID card is:");
String idno=scan.next();
System.out.println(idno);
System.out.print("The deposit now is:");
double deposit=scan.nextDouble();
System.out.println(deposit);
account[i]=new Account(accno,names,times,idno,deposit);
AccountOper.Choose();
int a=scan.nextInt();
try{
while(a!=4){
switch(a){
case(1):
account[i].Deposit(account[i]);
break;
case(2):
account[i].Withdraw(account[i]);
break;
case(3):
System.out.println("The account number:"+account[i].accno);
System.out.println("The name:"+account[i].names);
System.out.println("The time of account beginning:"+account[i].times);
System.out.println("The number of ID card:"+account[i].idno);
System.out.println("The deposit now:"+account[i].deposit);
break;
default:
break;
}
AccountOper.Choose();
a=scan.nextInt();
}}catch(IOException e){
System.out.println("Error!");
}
}
}
}
评论5
最新资源