Tryin to get the "Division by zero not allowed" part working ca someone help please :cry:
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.applet.Applet;
public class JDivideMe extends Applet {
private TextField numeratorField = new TextField( 10 );
private TextField denominatorField = new TextField( 10 );
private Label theAnswer = new Label("your answer is");
private Button divideButton;
public static final String DIVIDE = "divide";
public JDivideMe() {
super();
}
public void doDivide() {
double numerator = Double.parseDouble(numeratorField.getText());
double denominator = Double.parseDouble(denominatorField.getText());
if (denominatorField == zero) {
System.out.println("Division by zero not allowed");
} else {
double result = numerator/denominator;
theAnswer.setText(" = " + result );
}
}
public void init() {
divideButton = new Button("/");
divideButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doDivide();
}
});
add(divideButton);
add(numeratorField);
add(denominatorField);
add(theAnswer);
}
}