import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class ComputeAverageApplet extends Applet implements ActionListener{

TextField txtQuiz1;
TextField txtQuiz2;
TextField txtQuiz3;
TextField txtAve;
Label lblQuiz;
Label lblAverage;
Button cmdCompute;

public void init(){
lblQuiz = new Label(“Enter three quizzes: “);
add(lblQuiz);
txtQuiz1 = new TextField(3);
add(txtQuiz1);
txtQuiz2 = new TextField(3);
add(txtQuiz2);
txtQuiz3 = new TextField(3);
add(txtQuiz3);
cmdCompute = new Button(“Compute”);
add(cmdCompute);
lblAverage = new Label(“The average quiz is: “);
add(lblAverage);
txtAve = new TextField(7);
add(txtAve);
cmdCompute.addActionListener(this);
}

public void actionPerformed(ActionEvent e){
int quiz1;
int quiz2;
int quiz3;
double average=0.0;
if(e.getSource()==cmdCompute){
quiz1=Integer.parseInt(txtQuiz1.getText());
quiz2=Integer.parseInt(txtQuiz2.getText());
quiz3=Integer.parseInt(txtQuiz3.getText());
average = (quiz1+quiz2+quiz3)/3;
txtAve.setText(String.valueOf(average));
}
}
}