isLeapYear(int year). This methods should return true, if the year given
as a parameter is a leap year and false otherwise.
Does this accomplish that?
Im not sure, if I'm doing it right and I also have to write a tester, but I wanna make sure my class atleast works first.
a tester that reads three years from the user using a scanner and each of these inputs is tested if it is a leap year.
Im unsure of how to call the static method in the tester ... How can I make the tester call on the static method and then tell the user they cant use a number outside of 1900-2299.
As always thanks for the help.
David O'Meara wrote:Static methods 'belong' to the Class and not an instance, so rather than having new LeapYearExpert() you just need to refer to teh class alone ie LeapYearExpert.isLeapYear(year)
huh.....? in what context would I use it, Im a little lost at the moment, I've been reading, trying to google for help to no avail. My book doesnt cover this stuff well at all.
Sorry if its a dumb question.
public static void main (String  args )
/** Scanner to read user input*/
Scanner reader = new Scanner(System.in);
System.out.println ( " Enter a Year from 1900 to 2299: ");
int newYear = reader.nextInt();
boolean leap = LeapYearExpert.isLeapYear(newYear);
System.out.println("It is a Leap Year");
System.out.println("It is not a Leap year");
if you want to get three years, then you need to use some loop to repeat the same thing for three times
All you achieve by giving such an answer is depriving the other person of the chance to learn. Don't be annoyed, but I have pulled rank and deleted the solution.
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.