OMFG... it works it works it WORKS. It does EXACTLY what it's supposed to do! Except for one thing
Consider the following code:
System.out.println("Next, please enter either \"C\" or \"c\" for a");
System.out.println("Celsius-Fahrenheit conversion, or \"F\" or \"f\"");
System.out.println("for a Fahrenheit-Celsius conversion:");
System.out.println();
// typeOfConversion = (char)typeOfConversion;
typeOfConversion = keyboard.next();
switch (typeOfConversion.charAt(0))
{
case 'C':
case 'c':
result = 5.0 * ((double)degreeValue - 32.0) / 9.0;
System.out.println();
System.out.println(degreeValue + " Fahrenheit is " + result + " Celsius");
break;
case 'F':
case 'f':
result = (9.0 * ((double)degreeValue) / 5.0) + 32.0;
System.out.println();
System.out.println(degreeValue + " Celsius is " + result + " Fahrenheit");
break;
default:
System.out.println();
System.out.println("Oops! Your entry is invalid. Please enter either");
System.out.println("\"F\" or \"C\". The letter case does not matter.");
break;
}
After the default OOPS printout... which occurs when the user enters anything but F, f, C, or c... the whole program ends and starts over. Of course, because it's got a break statement there. But how could I loop it in such a way that the user only has to continue from this point of invalid entry? In other words, how do I let the user RETRY/REENTER the correct value, rather than having the whole program end right there and start from the beginning?
Thank you