A
A
*;
import java.awt.event.*;
// Display field
display = new TextField();
display.setEditable(false);
display.setFont(new Font("Arial", Font.BOLD, 30));
// Wrap the text field in a panel to make it span the full length
Panel displayPanel = new Panel();
displayPanel.setLayout(new BorderLayout());
displayPanel.add(display, BorderLayout.CENTER);
// Perform operation
switch (operator) {
case "+":
result = operand1 + operand2;
break;
case "-":
result = operand1 - operand2;
break;
case "*":
result = operand1 * operand2;
break;
case "/":
if (operand2 != 0) {
result = operand1 / operand2;
} else {
display.setText("Error: Divide by 0");
return;
}
break;
}