我需要一些邏輯幫助以及一些代碼幫助。使用日期計算利息時遇到問題
我正在寫的假設是一個簡單的ATM程序的程序。它將進行存款提款和餘額檢查。
我也得有我的節目錄制每一個存款的日期,計算當用戶檢查自己的資產負債5%的利息時使用日期。存在問題的部分是我需要存儲存款金額的部分以及與該存款相對應的日期。我應該使用GregorianCalender方法。我只是在黑暗中射擊,但我想我會用這個陣列。但即使如何執行它也一無所知。因爲我是數組的新手。
,一旦我得到一個日期,檢查平衡時,我需要檢查多少個月了一直以來該數額的存款計算利息。對不起,它是一個非常複雜的問題,但我是一個新手,這是以前寫過的最複雜的事情。
public void printDeposit(){
Calendar c = new GregorianCalendar();
BigDecimal depositamt;
Date date = c.getTime();
int menuselection;
System.out.println("Press 1 to deposit, zero to return to the main menu.");
Scanner sc = new Scanner (System.in);
menuselection = sc.nextInt();
if (menuselection==1){
System.out.println("Please enter the amount: " + date);
depositamt = sc.nextBigDecimal();
Transaction tran = new Transaction(depositamt, date);
}
public class Transaction {
BigDecimal amt;
Date date;
public Transaction(BigDecimal amt, Date date) {
this.amt = amt;
this.date = date;
}
我沒有看到數據結構中存儲最後一個tranasction日期的任何字段。 –