import javax.swing.*;
import java.awt.Container;
import java.math.*;
public class arithmetic extends JApplet {
public void init() {
String input = JOptionPane.showInputDialog
("Select an option (1(multiply),2(divide),3(add),4(subtract))");
int input2 = Integer.parseInt(input);
int choice = input2;
switch (choice) {
case 1:
for (int x = 1; x < 2; x++) {
int i = 1;
while( i < 2) {
double number1 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number1,null,JO ptionPane.
INFORMATION_MESSAGE);
double number2 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number2,null,JO ptionPane.
INFORMATION_MESSAGE);
String numberx = JOptionPane.showInputDialog("Enter result");
double number3 = Double.parseDouble(numberx);
double result = number1 * number2;
if (result == number3) {
JOptionPane.showMessageDialog(null,"correct",null,
JOptionPane.INFORMATION_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"wrong",null,
JOptionPane.INFORMATION_MESSAGE);
}
}
case 2:
for (int x = 1; x < 2; x++) {
double number4 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number4,null,JO ptionPane.
INFORMATION_MESSAGE);
double number5 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number5,null,JO ptionPane.
INFORMATION_MESSAGE);
String number7 = JOptionPane.showInputDialog("Enter result");
double number6 = Double.parseDouble(number7);
double result2 = Math.round(number4 / number5);
if (result2 == number6) {
JOptionPane.showMessageDialog(null,"correct",null,
JOptionPane.INFORMATION_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"wrong",null,
JOptionPane.INFORMATION_MESSAGE);
}
case 3:
for (int x = 1; x < 2; x++) {
double number8 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number8,null,JO ptionPane.
INFORMATION_MESSAGE);
double number9 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number9,null,JO ptionPane.
INFORMATION_MESSAGE);
String number10 = JOptionPane.showInputDialog("Enter result");
double number11 = Double.parseDouble(number10);
double result3 = number8 + number9;
if (result3 == number11) {
JOptionPane.showMessageDialog(null,"correct",null,
JOptionPane.INFORMATION_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"wrong",null,
JOptionPane.INFORMATION_MESSAGE);
}
case 4:
for (int x = 1; x < 2; x++) {
double number12 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number12,null,J OptionPane.
INFORMATION_MESSAGE);
double number13 = Math.floor(Math.random() * 13);
JOptionPane.showMessageDialog(null,number13,null,J OptionPane.
INFORMATION_MESSAGE);
String number14 = JOptionPane.showInputDialog("Enter result");
double number15 = Double.parseDouble(number14);
double result4 = number12 - number13;
if (result4 == number15) {
JOptionPane.showMessageDialog(null,"correct",null,
JOptionPane.INFORMATION_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"wrong",null,
JOptionPane.INFORMATION_MESSAGE);
}
}
}
}