1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| import java.io.*;
class account
{
String account = "-1";
int money = 0;
account(String ID, int money)
{
this.account = ID;
this.money = money;
}
void takeMoney(int m)
{
System.out.println(this.account+"f");
}
void saveMoney(int m)
{
this.money += m;
}
void showMoney()
{
System.out.println(this.account + " 存款餘額為 : " + this.money);
return this.money;
}
}
class Bank
{
public static void main(String args[])throws IOException
{
int action = 0;
int index = 0;
account user[] = new account[255];
while(action != -1)
{
System.out.println("輸入使用的功能\n1.建立帳戶\n2.存款\n3.提款\n4.查詢餘額");
System.out.println("輸入-1離開");
BufferedReader Bf = new BufferedReader(new InputStreamReader(System.in));
String buffer = Bf.readLine();
action = Integer.parseInt(buffer);
if(action == 1)
{
System.out.println("輸入新增帳戶名:");
BufferedReader Buf = new BufferedReader(new InputStreamReader(System.in));
String ID = Buf.readLine();
user[index] = new account(ID, 0);
index++;
}
else if(action == 2)
{
int money;
int m;
int usable = 0;
int select;
System.out.println("可操作的帳號編號:");
for(usable = 0; usable < index; usable++)
{
System.out.println("編號 : " + usable + " 帳號名稱 : " + user[usable].account);
}
System.out.println("Select user :");
BufferedReader Bs = new BufferedReader(new InputStreamReader(System.in));
String s = Bs.readLine();
select = Integer.parseInt(s);
if(select > usable){
}
else{
System.out.println("預存入多少金額:");
BufferedReader Br = new BufferedReader(new InputStreamReader(System.in));
String f = Br.readLine();
m = Integer.parseInt(f);
user[select].saveMoney(m);
}
}
else if(action == 3)
{
}
else if(action == 4)
{
int number = 0;
int inputBuf;
String IDNO;
System.out.println("可使用的帳號編號:");
for(number = 0; number < index; number++)
{
System.out.println("編號 : " + number + " 帳號名稱 : " + user[number].account + "餘額 : " + user[number].showMoney());
}
number = 0;
System.out.println("輸入欲查詢的帳號編號 : ");
BufferedReader Buff = new BufferedReader(new InputStreamReader(System.in));
String num = Buff.readLine();
inputBuf = Integer.parseInt(num);
if(inputBuf > number)
{
System.out.println("輸入編號錯誤");
}
else
user[number].showMoney();
}
else if(action == -1);
else
{
System.out.println("輸入錯誤");
}
}
}
}
|