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

In a class named Seasons, write a program that takes an input number representin

ID: 3822628 • Letter: I

Question

In a class named Seasons, write a program that takes an input number representing a month: an integer from 1 to 12 (January to December). Then program should output what season that month is in ( Winter, Spring, Summer, Fall).

In the the program should be a method called getSeason that takes one parameter, an int representing a month value, and should return a String value representing the season that month is in.

If the month value is for January through March (1 through 3), then getSeason should return "winter".

If the month value is for April through June (4 through 6), then getSeason should return "spring".

If the month value is for July through September (7 through 9), then getSeason should return "summer".

If the month value is for October through December (10 through 12), then getSeason should return "fall".

The getSeason method should be called from your program's main method and its return value should be printed out in the main method.

Example should look like:

This is in Java.

Explanation / Answer


public class CalenderSeason
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);

System.out.println("This code shows the season for a given day and month");
System.out.println("Please enter the month and day");

int month = keyboard.nextInt();
int day = keyboard.nextInt();


if ( (month == 1) || (month == 2))
System.out.println("The season is Winter");

else if ( (month == 4) || (month == 5))
System.out.println("The season is Spring");

else if ( (month == 7) || (month == 8))
System.out.println("The season is Summer");

else if ( (month == 10)|| (month == 11))
System.out.println("The season is Fall");

else if ( (month == 3) && (day <= 19 ))
System.out.println("The season is Winter");

else if ( (month == 3) && (day >= 20 ))
System.out.println("The season is Spring");

else if ( (month == 6) && (day <= 20 ))
System.out.println("The season is Spring");

else if ( (month == 6) && (day >= 21 ))
System.out.println("The season is Summer");

else if ( (month == 9) && (day <= 20 ))
System.out.println("The season is Summer");

else if ( (month == 9) && (day >= 21 ))
System.out.println("The season is Autumn");

else if ( (month == 12) && (day <= 21 ))
System.out.println("The season is Autumn");

else if ( (month == 12) && (day >= 22 ))
System.out.println("The season is Winter");


}

}