I have to create a calendar for class. It has to manually display the date (day of week, month, date, year) after the user inputs: mm dd yyyy.
I have the input and the verification of the values and all of that good stuff, but i want it to either exit or restart the entire program if the verification fails. this is what i have:
System.out.println("Enter the date in MM DD YYYY format please. The spaces are very important!");
Scanner console= new Scanner(System.in);
if (month>= 1 && month<=12) System.out.println("Good Month");
else System.out.println("There are only 12 months!");
the exit, or restart has to go after a message is displayed to the user.
As you probably already know, Java is a statically typed language - all variables have a type, which is fixed at the moment you write your source code. You have declared the variable month as an int so it can contain only integer numbers. An assignment statement like month = "January"; is not going to work, because you cannot assign a string "January" to an int variable. You'll have to create a different variable to hold the name of the month. You could for example call it monthName and make it a String.