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

develop a set of test cases for the following algorithm this algorithm yields th

ID: 3550437 • Letter: D

Question

develop a set of test cases for the following algorithm

this algorithm yields the season( spring, summer, fall, and winter) for a given month and day.

if month is 1,2, or 3, season = "winter"

Else if month is 4,5, or 6, season = "spring"

Else if month is 7,8, or 9, season = "summer"

Else if month is 10,11,or 12, season = "fall"

If month is divisible by 3 and day >= 21

       If season is "winter", season = "spring"

       Else if season is "spring", season = "summer'

       Else if season is "summer", season = "fall"

       Else season = "winter'

write a program that prompts the user for a month and day and then prints the season, as determined by this algorithm.

Use a class Date with a method getSeason

Explanation / Answer

import java.util.Scanner;


public class Seasons {


public static void main (String[] args){


Scanner in = new Scanner(System.in);

int month;

int day;

String season = null;


System.out.print("Please enter month and day: ");

month = in.nextInt();

day = in.nextInt();


if(1 <= month && month <=3){

season = "Winter";

System.out.println(season);

}


else if (4 <= month && month <=6){

season = "Spring";

System.out.println(season);

}


else if (7 <=month && month <=9){

season = "Summer";

System.out.println(season);

}


else if (10 <= month && month <= 12){

season = "Fall";

System.out.println(season);

}



if ( ((month % 3 == 0) && (21 <= day)){

if (season.equals("Winter")){


}


else if (season.equals("Spring")){

season = ("Summer");

}


else if (season.equals("Summer")){

season = "Fall";

}


else {

season = "Winter";

}



}

}

}





Based on the conditions it should work like this: