I am learning java in the internet in sites like "oracle academy" and using Google to search how to do somethings, i wanted to make a simple java program that takes an number(day) a number or word(month) and another number(year), so if you input something like
"3" "1" and "1993"
it outputs
"January 1st, 1993"
and if you input something like
"2" "July" and "1992"
it outputs
"7/2/1992"
I kind of already know how to make it using "case" and while loops to tell you if you input something incorrectly, but on the "day" part i tried using a while loop to keep asking you to input something if the input wasn't a number between 1 and 31 but i can't make it return the number from the while loop using the return command, is there any way to return the number without using the return command or not? the code:
public static void main(String[] args) {
String x;
Scanner scan = new Scanner(System.in);
//day
System.out.println("Insert Day");
while (1 < 2){
x = scan.nextLine();
if (x.matches(".*\\d.*")){
q = Integer.parseInt(x);
if ((0 < q) && (q < 32)){
return q;
}
else {
System.out.println("please use a valid number");
}
}
else {
System.out.println("please use a number");
}
}
System.out.println(q);
SimpleDateFormat.