第5周作业-贷款计算器程序
来源:互联网 发布:java 关闭 一个 进程 编辑:程序博客网 时间:2024/05/02 00:20
import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.TitledBorder;public class LoanCalculator extends JFrame {private JTextField jtfAnnualInterestRate = new JTextField();private JTextField jtfNumberofYears = new JTextField();private JTextField jtfLoanAmount = new JTextField();private JTextField jtfMonthlyPayment = new JTextField();private JTextField jtfTotalPayment = new JTextField();private JButton jbtComputeLoan = new JButton("Compute Payment");public LoanCalculator() {JPanel p1 = new JPanel(new GridLayout(5,2));p1.add(new JLabel("Annual Interest Rate"));p1.add(jtfAnnualInterestRate);p1.add(new JLabel("Number of Years"));p1.add(jtfNumberofYears);p1.add(new JLabel("Loan Amount"));p1.add(jtfLoanAmount);p1.add(new JLabel("Monthly Payment"));p1.add(jtfMonthlyPayment);p1.add(new JLabel("Total Payment"));p1.add(jtfTotalPayment);p1.setBorder(new TitledBorder("Enter loan amout,interest rate,and year"));JPanel p2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));p2.add(jbtComputeLoan);add(p1,BorderLayout.CENTER);add(p2,BorderLayout.SOUTH);jbtComputeLoan.addActionListener(new ButtonListener());}private class ButtonListener implements ActionListener {public void actionPerformed(ActionEvent e ) {double interest = Double.parseDouble(jtfAnnualInterestRate.getText());int year =Integer.parseInt(jtfNumberofYears.getText());Double .parseDouble(jtfLoanAmount.getText());Loan loan = new Loan (interest,year,loanAmount);//Loan loan = new Loan(interest,year,loanAmount);jtfMonthlyPayment.setText(String.format("%.2f",loan.getMonthlyPayment()));jtfTotalPayment.setText(String.format("%.2f",loan.getTotalPayment()));}} public static void main(String[] args){ LoanCalculator frame = new LoanCalculator(); frame.pack(); frame.setTitle("LoanCaculator"); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);}}
0 0
- 第5周作业-贷款计算器程序
- 第5周作业-贷款计算器程序
- 第5周作业-贷款计算器程序
- 第4周作业-贷款计算器程序
- 第5周作业-时钟动画程序
- 第5周作业-时钟动画程序
- 第5周作业-时钟动画程序
- 第一个android程序——贷款计算器
- 第9周-窗口程序-小型计算器
- 购房贷款计算器
- 二手房贷款计算器
- 两个贷款计算器
- JavaScript贷款计算器
- 第5周作业-打字成绩判断程序
- 第5周作业-打字成绩判断程序GUI
- 第5周作业-时钟动画程序(15-9)
- 第5周作业-打字成绩判断程序TouchType
- 第5周作业-打字成绩判断程序
- 模仿MFC消息驱动机制
- You Win! 状态压缩dp
- ICMP,ARP,DHCP
- P1045 Kerry 的电缆网络(Kruskal+并查集)
- android 2.3 电源管理
- 第5周作业-贷款计算器程序
- Java List接口
- OpenStack最新版本Folsom架构解析
- 第四周作业——图的表示
- Oracle EBS - What happening when executing adpreclone.pl in DB and Apps Tier?
- 黑马程序员 OC------- id类型: 构造方法学习
- UI编程为何选择QT
- LDA最佳学习资料汇总
- unity 3D 场景缩放代码