I am trying to figure out how to validate the input of a user. I want the user to enter a double but if the user enters a string I want the question repeated until a double is entered. Iv'e searched but I couldn't find anything. Below is my code so far any help is appreciated. I have to use a do while loop I am stuck on what to put in the while loop to make sure the input is a double and not a string.
public class FarenheitToCelsius {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double fahrenheit, celsius;
Scanner in = new Scanner(System.in);
do{
System.out.printf("Enter a fahrenheit degree: ");
fahrenheit = in.nextDouble();
}
while();
celsius = ((fahrenheit - 32)*5)/9;
System.out.println("Celsius value of Fahrenheit value " + fahrenheit + " is " + celsius);