Hi, does anyone know how to set a limit to a number a user inputs? I am making a practice program that determines the price of a customers order and I need to set a limit to how many items they are allowed to purchase. The limit is 40.
here is what I have:
if ( number >40 )
System.out.print( "Error: Limited number of items available. Please enter a number under 40. " );
This works for displaying an error message, however I would like the customer to be able to enter another number after they receive that error. So it would look like this
Please enter a number: 45
Error: Limited number of items available. Please enter a number under 40.
Please enter a number: <---------(loops back to original question)
Thanks!!!