I only have 1 problem in my code,
Code:
import javax.swing.JOptionPane;
import java.util.Scanner;
public class FLABWORK3_ABUEL
{
static Scanner Scan = new Scanner (System.in);
public static void main(String[] args)
{
String choice;
String num1;
String string;
String Inverse;
int choicee, num2, response, length;
double squareroot;
Object[] options = {"Yes", "No"};
do {
choice = JOptionPane.showInputDialog("Main Menu" +
"\n 1. Square of a number" +
"\n 2. Square root a number" +
"\n 3. Cube of a number" +
"\n 4. Length of number" +
"\n 5. Inverse of a string");
choicee = Integer.parseInt(choice);
while (choicee > 5)
{
choice = JOptionPane.showInputDialog("Enter only 1-5!");
}
if (choicee == 1)
{
num1 = JOptionPane.showInputDialog("Enter an number.");
num2 = Integer.parseInt(num1);
num2 = num2*num2 ;
JOptionPane.showMessageDialog(null, "The square of the number: " + num2);
} else if (choicee == 2)
{
num1 = JOptionPane.showInputDialog("Enter a number.");
squareroot = Integer.parseInt(num1);
squareroot = Math.sqrt(squareroot);
JOptionPane.showMessageDialog(null, "Square root is: " + squareroot);
} else if (choicee == 3)
{
num1 = JOptionPane.showInputDialog("Enter a number.");
num2 = Integer.parseInt(num1);
num2 = num2*(num2*num2);
JOptionPane.showMessageDialog(null, "The cube is: " + num2);
} else if (choicee == 4)
{
string = JOptionPane.showInputDialog("Enter a sentence or a word.");
length = string.length();
JOptionPane.showMessageDialog(null, "The length : " + "\n" + length + "\n\n" +
"is:" + string);
}
else if (choicee == 5) {
string = JOptionPane.showInputDialog("Enter a word.");
length = string.length();
for (int i = length - 1; i >= 0; i--)
Inverse = Inverse + string.charAt(i);
response = JOptionPane.showInputDialog(null,
"Would you like to try again?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
}
}
while (response == JOptionPane.YES_OPTION);
}
}
The error is