Objective of Code: I need a write a code that will allow for a user to insert a year, and the code will tell them if it is a leap year by dividing it by 4. If the year is a leap year, the code will output the text "[YEAR] is a leap year." If not, it will produce "[YEAR] is NOT a leap year."
Error with the Code (as it is included below): Whenever I run the code, I
do get the option to enter the year I want to evaluate. However, once I enter it, nothing happens. I'm not receiving any specific error message. I thought this meant that I needed to change my code in some way to include some sort of message to output a statement like those included above ("[YEAR] is/is NOT a leap year."), but my attempts (included after my code) to fix it haven't worked.
Code (As Is):
The following code is in the main of one class (Main.java).
The following code is in the main of another class (LeapYear.java).
Attempt to fix 1: I added the statement-
To my main in Main.java after-
Because there was a similar statement included in another batch of code I'm worked on a few weeks ago. However, this change resulted in this error:
I'm not quite sure what this error means (I'm pretty new to
Java), so I just tried something else.
Attempt to fix 2: I deleted the code I added in
Attempt to fix 1 and tried to make my return statements-
Into statements like-
and-
But I got the error that I was missing a return statement. I tried adding return to the beginning of the new out.println statements above, but got this error-
In Conclusion
How can I make my code output the appropriate "[YEAR] is/is NOT a leap year." statements? Thank you!
(I tried to be thorough in my explanation of what I was trying to do/what I tried in order to fix my error, but if I missed something please let me know!)