I am making a temperature converter and I ran into the following issue:
Would you like to make another conversion ? (Y/N)
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at Main.main(Main.java:79)
exit status 1
You can check out the full code here https://repl.it/@KyrillHuet/Temperature-Converter
And it seems that the first part works just fine but the last parst is causing the issue.
do{
do{//New coversion?
System.out.println();
System.out.println("Would you like to make another conversion ? (Y/N)");
response = sc.nextLine().charAt(0);
} while (response != 'Y' & response != 'N'); // Filtering other awnsers than Y or N.
} while (response == 'Y');
I just started to learn java and in when I looked and checked with my book but everything seems fine. Help would be greatly appreciated. =)