Recursion Code Extensive
Recursion Code Extensive
JOptionPane;
while(running){
int choice = JOptionPane.showOptionDialog(null, "Please choose",
"Recursion Practice", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
null, choices, choices[0]);
switch(choice){
case 0:
int x = Integer.parseInt(JOptionPane.showInputDialog("Enter
Base Number"));
int y = Integer.parseInt(JOptionPane.showInputDialog("Enter
Exponent Number"));
JOptionPane.showMessageDialog(null, power(x,y));
break;
case 1:
int z = Integer.parseInt(JOptionPane.showInputDialog("Enter
Factorial Number"));
JOptionPane.showMessageDialog(null, factorial(z));
break;
case 2:
int a = Integer.parseInt(JOptionPane.showInputDialog("Enter
Fibonacci Number"));
JOptionPane.showMessageDialog(null, Fibonacci_Sequence(a));
break;
case 3:
int b = Integer.parseInt(JOptionPane.showInputDialog("Enter
Fibonacci Number"));
JOptionPane.showMessageDialog(null, Height(b));
break;
case 4:
int exit = JOptionPane.showConfirmDialog(null, "Are you sure
you want to exit?", "Exit", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if(exit == JOptionPane.YES_OPTION){
JOptionPane.showMessageDialog(null, "Closing Program...");
running = false;
}
break;
}
}
}