//Calculator4Applet.java import javax.swing.*; import java.awt.*; public class Calculator4Applet extends JApplet { int num1; int num2; public void init () { String input; input = JOptionPane.showInputDialog("Enter first integer"); num1 = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter second integer"); num2 = Integer.parseInt(input); } public void paint( Graphics g ) { int sum, difference, product, quotient=0, remainder=0; sum = num1 + num2; difference = num1 - num2; product = num1 * num2; if (num2 != 0) quotient = num1 / num2; if (num2 != 0) remainder = num1 % num2; g.setFont( new Font( "Courier", Font.BOLD, 24 ) ); g.drawString("Sum is " + sum, 10, 20); g.drawString("Difference is " + difference, 10, 40); g.drawString("Product is " + product, 10, 60); if (num2 != 0) g.drawString("Quotient is " + quotient, 10, 80); else g.drawString ("Qutoient not calculated", 10,80); if (num2 != 0) g.drawString("Remainder is " + remainder, 10, 100); else g.drawString ("Remainder not calculated", 10,100); //can compare two numeric variables: if (num1 == num2) g.drawString("they equal!",10,120); else g.drawString("they don't equal!",10,120); } } /* merge the two if statements into one, as they ask the same question */