I'm a noob, so I apologize if I'm asking a stupid question. I'm asking a user to input a numerical value. If the value is less than 12, or a non-numerical value such as a number, I want it to prompt them for another input. When a value of at least 12 is entered, I want that value to assigned to a variable called creditUnits;
When I ask for the initial prompt, my program will catch it if the value entered is non-numerical, it will ask the user to "Enter a valid number:". The while loop seems to work well.
I'm having an issue with the second loop, where it is supposed to catch any number entered in that is less than 12. It will ask the user to enter a value greater than 11. Problem I'm having is at this point if the user enters any value at this point, the program just sits there. Any help would be appreciated, and I apologize in advance for the sloppiness of my code:
System.out.print("Enter the credits's you will take each term: ");
while (!in.hasNextDouble()){
System.out.print("Enter a valid number: ");
in.next();
}
creditUnits = in.nextDouble();
if (creditUnits < 12){
System.out.print("Enter a number greater than 11: ");
in.next();
}
creditUnits = in.nextDouble();
System.out.println("You will be taking " + creditUnits + " credits per term.");
hasNextDouble()withhasNextInt(). By the way, I agree with Secator: there are no stupid questions; specifically, your question is not stupid at all ;)