JAVA CODE

//Ex2_12 program
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Ex2_12 extends Applet implements ActionListener
{
  Label Lbl1, Lbl2, Lbl3, Lbl4, Lbl5;
  TextField Txt1, Txt2, Txt3, Txt4, Txt5;
  int Num1, Num2, Num3, Num4, Num5;

  public void init()
  {
    Lbl1 = new Label("Enter Account:");
    add(Lbl1);

    Txt1 = new TextField(3);
    Txt1.addActionListener(this);
    add(Txt1);

    Lbl2 = new Label("Enter Balance:");
    add(Lbl2);

    Txt2 = new TextField(3);
    Txt2.addActionListener(this);
    add(Txt2);

    Lbl3 = new Label("Enter Charges:");
    add(Lbl3);

    Txt3 = new TextField(3);
    Txt3.addActionListener(this);
    add(Txt3);

    Lbl4 = new Label("Enter Credits:");
    add(Lbl4);

    Txt4 = new TextField(3);
    Txt4.addActionListener(this);
    add(Txt4);

    Lbl5 = new Label("Enter Credit Limit:");
    add(Lbl5);

    Txt5 = new TextField(3);
    Txt5.addActionListener(this);
    add(Txt5);
  }

  public void paint (Graphics g)
  {
     int nb = Num2 + Num3 - Num4;
       g.drawString("The New Balance : " + nb, 80, 80);

     if (nb > Num2)
       g.drawString("Credit limit exceeded.", 80, 100);

     else
       {}
   }

   public void actionPerformed( ActionEvent e )
   {
     Num1 = Integer.parseInt( Txt1.getText() );
     Num2 = Integer.parseInt( Txt2.getText() );
     Num3 = Integer.parseInt( Txt3.getText() );
     Num4 = Integer.parseInt( Txt4.getText() );
     Num5 = Integer.parseInt( Txt5.getText() );
     repaint();
   }
}