0

所以我一直在尝试为我正在做的这个项目创建一个银行账户 GUI。我遇到的问题是,当尝试存款时,TextField 允许人们输入金额以添加到余额中。完成此操作后,我还希望将已存入另一个标签的内容存入另一个标签,该标签在输入的金额之上显示利息。

这是我到目前为止创建的

double CredAccInterest = 1;
double CurrAccInterest = 0.1;
double DepAccInterest = 3;
double SavAccInterest = 0.5;

double Deposit = Integer.parseInt(txtDeposit.getText());
double Balance = Integer.parseInt(lblSetBalance.getText());
double NewBalance = Balance + Deposit;
String NewBalWithDeposit = String.valueOf(NewBalance);
lblSetBalance.setText(NewBalWithDeposit);  

Object AccountType = cbAccounts.getSelectedItem();

String AccType = AccountType.toString();

if("Credit Account".equals(AccType))
     {
       String CurrentInterest = lblSetBalanceWithInterest.getText();
       double CurrentInterestInt = Integer.parseInt(CurrentInterest);
       double InterestAmount = Deposit * CredAccInterest;
       double NewInterestAmount = InterestAmount + CurrentInterestInt;
       String NewInterest = String.valueOf(NewInterestAmount);
       lblSetBalanceWithInterest.setText(NewInterest);
     }
4

0 回答 0