Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a method named season that takes two integers as parameters representing a

ID: 654739 • Letter: W

Question

Write a method named season that takes two integers as parameters representing a month and day and that returns a Stringindicating the season for that month and day. Assume that months are specified as an integer between 1 and 12 (1 for January, 2 for February, and so on) and that the day of the month is a number between 1 and 31.

If the date falls between 12/16 and 3/15, you should return "Winter". If the date falls between 3/16 and 6/15, you should return "Spring". If the date falls between 6/16 and 9/15, you should return "Summer". And if the date falls between 9/16 and 12/15, you should return "Fall".

Explanation / Answer

Hi, here's the method. Thanks

public static String season(int month, int day)
{

if ((month == 12 && day >= 16) || (month == 3 || day <= 15) || (month == 1 || month == 2))
return "Winter";

if ((month == 3 && day >= 16) || (month == 6 || day <= 15) || (month == 4 || month == 5))
return "Spring";

if ((month == 6 && day >= 16) || (month == 9 || day <= 15) || (month == 7 || month == 8))
return "Summer";

if ((month == 9 && day >= 16) || (month == 12 || day <= 15) || (month == 10 || month == 11))
return "Fall";

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote