JAVA CODE
//Arithmetic Tuto example import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class ArithTutor extends Applet implements ActionListener { Label AddLabel, EqualLabel, ReplyLabel; TextField NumText1, NumText2, AnswerText; Button GradeButton; int Num1,Num2,Answer; public void init() { NumText1 = new TextField(3); add(NumText1); NumText1.setEditable(false); AddLabel = new Label(" + "); add(AddLabel); NumText2 = new TextField(3); add(NumText2); NumText2.setEditable(false); EqualLabel = new Label(" = "); add(AnswerText); GradeButton = new Button("Mark"); GradeButton.addActionListener(this); add(GradeButton); ReplyLabel = new Label(); add(ReplyLabel); Num1 = (int) (Math.random()*10); Num2 = (int) (Math.random()*10); NumText1.setText(Integer.toString(Num1)); NumText2.setText(Integer.toString(Num1)); } public void actionPerformed( ActionEvent e ) { Answer = Integer.valueOf(AnswerText.getText()).intValue(); if ((Num1 + Num2)==Answer) ReplyLabel.setText("Right"); else ReplyLabel.setText("Wrong"); Num1 = (int) (Math.random()*10); Num2 = (int) (Math.random()*10); NumText1.setText(Integer.toString(Num1)); NumText2.setText(Integer.toString(Num2)); AnswerText.setText(""); repaint(); } }