//first java Applet import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Credit extends Applet implements ActionListener { Label promptNum, promptBegBal, promptCharges, promptCredit, promptLimit, promptResult; //Message tp porompt user TextField acctNum, begBal, totCharges, totCredit, limit, result; //input values entered here int number, balance, charges, credit, climit, total; public void init() { promptNum = new Label("Account Number"); add(promptNum); acctNum = new TextField(10); add(acctNum); acctNum.addActionListener(this); promptBegBal = new Label("Beginning Balance"); add(promptBegBal); begBal = new TextField(10); add(begBal); begBal.addActionListener(this); promptCharges = new Label("Charges"); add(promptCharges); totCharges = new TextField(10); add(totCharges); totCharges.addActionListener(this); promptCredit = new Label("Credit"); add(promptCredit); totCredit = new TextField(10); add(totCredit); totCredit.addActionListener(this); promptLimit = new Label("Limit"); add(promptLimit); limit = new TextField(10); add(limit); limit.addActionListener(this); promptResult = new Label("Result"); add(promptResult); result = new TextField(10); add(result); } public void actionPerformed(ActionEvent e) { if (acctNum.hasFocus()) { number = Integer.parseInt(e.getActionCommand()); } if (begBal.hasFocus()) { balance = Integer.parseInt(e.getActionCommand()); } if (totCharges.hasFocus()) { charges = Integer.parseInt(e.getActionCommand()); } if (totCredit.hasFocus()) { credit = Integer.parseInt(e.getActionCommand()); } if (limit.hasFocus()) { climit = Integer.parseInt(e.getActionCommand()); total = balance + charges - credit; result.setText(Integer.toString(total)); if (total > climit) { showStatus("You have exceeded your limit!"); } } } }