Answer to Question #287921 in Java | JSP | JSF for Srinivasa Reddy

Question #287921

The goal of this coding exam is to quickly get you off the ground with switch statement. given month as input,write a js program to find the corresponding season using switch statement

1
Expert's answer
2022-01-16T09:03:18-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String month = scanner.nextLine();

        System.out.println(findSeasonOf(month));
    }

    private static String findSeasonOf(String month) {
        switch (month.toLowerCase()) {
            case "december":
            case "january":
            case "february":
                return "Winter";
            case "march":
            case "april":
            case "may":
                return "Spring";
            case "june":
            case "july":
            case "august":
                return "Summer";
            case "september":
            case "october":
            case "november":
                return "Autumn";
            default:
                return "Unknown";
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog