Recurs I On With Max
Recurs I On With Max
JOptionPane;
while (running) {
int choice = JOptionPane.showOptionDialog(
null,
"Please choose an operation",
"Recursion Practice",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
choices,
choices[0]
);
switch (choice) {
case 0: // Power
int base = Integer.parseInt(JOptionPane.showInputDialog("Enter
Base Number"));
int exponent =
Integer.parseInt(JOptionPane.showInputDialog("Enter Exponent Number"));
JOptionPane.showMessageDialog(null, "Result: " +
RecursionMethods.power(base, exponent));
break;
case 1: // Factorial
int number =
Integer.parseInt(JOptionPane.showInputDialog("Enter Factorial Number"));
JOptionPane.showMessageDialog(null, "Result: " +
RecursionMethods.factorial(number));
break;
default:
running = false;
}
}
}
}