this is the menu for a loan calculator:
Please select one of the following options:
1. Calculate monthly payment
2. Calculate loan duration
x. Cancel
Enter your option (1, 2 or x) : x
i have used a switch statement for the variable option to choose the option desired.
CODE
switch (option)
{
// option 1
case 1:
this is the same for option 2.
but as the variable option is declared as int, option x fails to work. how do i get the user to choose option x without any errors????
this is what's displayed when i choose option x:
CODE
Enter your option (1, 2 or x) : x
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:819)
at java.util.Scanner.next(Scanner.java:1431)
at java.util.Scanner.nextInt(Scanner.java:2040)
at java.util.Scanner.nextInt(Scanner.java:2000)
at LoanCalculator.main(LoanCalculator.java:41)