?? bankaccount.java
字號:
import java.util.*;
class Account {
final int Max=5; //操作的次數
private int top; //儲戶帳目管理的指針
private int Ac_id; //帳號
private String Ac_name; //儲戶姓名
private long Ac_card; //儲戶身份證號
private String Ac_date[]=new String[Max]; //日期
private int Ac_money[]=new int[Max]; //金額
private int Ac_rest[]=new int[Max]; //余額
private static int Ac_sum=0; //累計余額
public Account()
{
top=0; //儲戶帳目管理的指針
Ac_id=0; //帳號
Ac_name=""; //儲戶姓名
Ac_card=0; //儲戶身份證號
Ac_sum=0; //Ac_sum清零
}
void Ac_in(String Ac_name,String aAc_date,int aAc_money) //存款方式
{
Ac_date[top]=aAc_date;
Ac_money[top]=aAc_money;
Ac_sum=Ac_sum+aAc_money;
Ac_rest[top]=Ac_sum;
System.out.println("儲戶姓名"+Ac_name+"日期"+Ac_date[top]+"存入"+Ac_money[top]+"存款余額"+Ac_rest[top]);
top++;
}
void Ac_out(String Ac_name,String aAc_date,int aAc_money) //取款方式
{
Ac_date[top]=aAc_date;
Ac_money[top]=-aAc_money;
Ac_sum=Ac_sum-aAc_money;
Ac_rest[top]=Ac_sum;
System.out.println("儲戶姓名"+Ac_name+"日期"+Ac_date[top]+"取出"+(-Ac_money[top])+"存款余額"+Ac_rest[top]);
top++;
}
void Ac_ask(String Ac_name,String aAc_date) //查詢方式
{
Ac_date[top]=aAc_date;
Ac_money[top]=0;
Ac_rest[top]=Ac_sum;
System.out.println("儲戶姓名"+Ac_name+"日期"+Ac_date[top]+"查詢存款余額"+Ac_rest[top]);
top++;
}
}
public class BankAccount
{
public static void main(String args[])
{
Account zhang=new Account();
zhang.Ac_in("張梁","2003.6.6",3000);
zhang.Ac_out("張梁","2003.6.8",2000);
zhang.Ac_in("張梁","2003.7.7",3000);
zhang.Ac_in("張梁","2003.7.9",1500);
zhang.Ac_ask("張梁","2003.7.10");
Account li=new Account();
li.Ac_in("李巖","2003.8.6",3000);
li.Ac_in("李巖","2003.8.7",2000);
li.Ac_in("李巖","2003.9.7",3000);
li.Ac_out("李巖","2003.9.9",1500);
li.Ac_ask("李巖","2003.9.10");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -