JAVA CODE
//Card program
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Card extends Applet
implements ActionListener
{
Label Num1Str,Num2Str;
TextField Num1Text,Num2Text;
int Num1, Num2;
public void init()
{
Num1Str = new Label("Input the 1st number : ");
add(Num1Str);
Num1Text = new TextField(10);
add(Num1Text);
Num2Str = new Label("Input the 2nd number : ");
add(Num2Str);
Num2Text = new TextField(10);
Num2Text.addActionListener(this);
add(Num2Text);
}
public void paint( Graphics g )
{
g.drawString("The Sum is " + (Num1+Num2), 10, 90 );
g.drawString("The Differences is " + (Num1-Num2), 10, 110 );
g.drawString("The Product is " + (Num1*Num2), 10, 130 );
g.drawString("The Quotient is " + ((float)Num1/Num2), 10,150 );
g.drawString("The Average is " + ((float)(Num1+Num2)/2), 10, 170 );
}
public void actionPerformed( ActionEvent e )
{
Num1 = Integer.parseInt(Num1Text.getText());
Num2 = Integer.parseInt(Num2Text.getText());
repaint();
}
}