📄 u7a1.java
字号:
//
import javax.swing.JApplet;
import javax.swing.JTextArea;
import java.awt.Container;
import java.awt.Font;
public class U7A1 extends JApplet
{
public void init()
{
String result ="Account Information\n-------------------\n\n";
BankAccount x = new BankAccount();
int xacc = x.getAccount();
BankAccount y = new BankAccount(1500);
int yacc = y.getAccount();
result+="Initial Balance for account "+ xacc +" = $ "+ String.format("%.2f",x.getBalance()) +"\n";
result+="Initial Balance for account "+ yacc +" = $ "+ String.format("%.2f",y.getBalance()) +"\n";
result +="\n";
result+=x.deposit(300) + "\n" + y.deposit(200)+"\n";
result+=x.withdraw(250) + "\n" + y.withdraw(125)+"\n";
double xinterest = x.calcInterest();
double yinterest = y.calcInterest();
if(550>x.getBalance())
{
result+=x.withdraw(550) + "\n";
result+=y.deposit(0) +"\n";
}
else
{
result+=x.withdraw(550) + "\n";
result+=y.deposit(550) +"\n";
}
xinterest = x.calcInterest();
yinterest = y.calcInterest();
result+="\n";
result+="Final Balance for account "+ xacc +" = $ "+ String.format("%.2f",x.getBalance()) +"\n";
result+="Final Balance for account "+ yacc +" = $ "+ String.format("%.2f",y.getBalance()) + "\n\n";
result+="Interest Rate = "+BankAccount.getInterest()+" %";
JTextArea h = new JTextArea();
h.setText(result);
Font myFont = new Font("Monospaced", Font.PLAIN, 14);
h.setFont(myFont);
Container container = getContentPane();
container.add(h);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -