import java.applet.*; import java.awt.*; import java.awt.event.*; public class CalculateBalance extends Applet implements ActionListener { Button calcButton = new Button("Enter"); Label enterBalance = new Label("Enter your Balance"); TextField balance = new TextField(5); Label enterCheck = new Label("Enter your Check"); TextField check = new TextField(5); Label enterDeposit = new Label("Enter your Deposit"); TextField deposit = new TextField(5); Label TotalResult = new Label(" "); public void init() { add(enterBalance); add(balance); add(enterCheck); add(check); add(enterDeposit); add(deposit); add(calcButton); add(TotalResult); calcButton.addActionListener(this); balance.addActionListener(this); check.addActionListener(this); deposit.addActionListener(this); } public void start() { invalidate(); validate(); } public void actionPerformed(ActionEvent e) { enterBalance.setLocation(10,10); balance.setLocation(350,10); enterCheck.setLocation(10,40); check.setLocation(350,40); enterDeposit.setLocation(10,70); deposit.setLocation(350,70); TotalResult.setLocation(40,200); int numBalance = Integer.parseInt(balance.getText()); int numCheck = Integer.parseInt(check.getText()); int numDeposit = Integer.parseInt(deposit.getText()); int x = numBalance - numCheck + numDeposit; TotalResult.setText("" + x); } }