Just wondering if you could help with this issue. code and output provided below.
do {
System.out.println("would you kindly enter your age?");
while (!sc.hasNext("[0-9]+")) {
System.out.println("Please only use numbers.");
sc.nextLine();
}
age = sc.nextByte();
if (age >= 18) {
System.out.println(""+age);}
else if (age <= 17) {
System.out.println("You must be 18 or older to rent a car if you input an incorrect age please try again otherwise close this page.");
}
} while (age <= 17);
System.out.println("Would you kindly enter the first line of your address?");
address1 = sc.nextLine();
System.out.println("Would you kindly enter the second line of your address?");
address2 = sc.nextLine();
System.out.println("Would you kindly enter the third line of your address");
address3 = sc.nextLine();
sc.close();
Output:
Would you kindly enter your name?
m
would you kindly enter your age?
122
Would you kindly enter the first line of your address?
Would you kindly enter the second line of your address?
1
Would you kindly enter the third line of your address
1