Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dates for each season: Spring: March 20 - June 20 Summer: June 21 - September 21 Autumn: September 22 - December 20 Winter: December

image text in transcribedimage text in transcribed

Dates for each season: Spring: March 20 - June 20 Summer: June 21 - September 21 Autumn: September 22 - December 20 Winter: December 21 - March 19 Sample Output: Enter a date (String, int): April 11 April 11 falls during Spring Enter a date (String, int): Blue 65 You entered an invalid date. Part 2: Seasons (Switch) TO DO: Solve the Seasons problem (described in Part 1) again, but this time, you should only use a switch statement (i.e. no IF, IF-ELSE or ELSE-IF). The desired output will remain the same. Name this program SeasonsSwitch.java Remember: Adhere to good programming practices (includes a header, comments, proper indentation, and descriptive variable names using camelCase) 4 Q 14 A File Edit Selection View Go Run Terminal Help J Cards.java 3 J Seasons.java 2 J SeasonsSwitch.java 2 C: > Users > 14848 > Documents > readings > J SeasonsSwitch.java > SeasonsSwitch > main(String[]) 7 import java.util.Scanner; 8 public class Seasons Switch { 0A7 9 PEGADGANG 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 PROBLEMS Run | Debug public static void main (String[] args) { Scanner sc = new Scanner(System.in); System.out.println(x: "Enter a date (String, int): "); String month = sc.next(); int day = sc.nextInt (); String season = ""; switch (month) { case "March": season=("Spring"); System.out.println( month+day + " falls under " + season); break; SeasonsSwitch.java - Visual Studio Code case "April": season=("Spring"); System.out.println( month + day + " falls under " break; case "May": OUTPUT DEBUG CONSOLE TERMINAL Type here to search + season); Septmber 11 invalid number PS C:\Users\14848> & 'C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot\bin\java.exe' '-cp' 'C:\Users\14848\AppData\Local\Temp\vscodesws_ 5718f\jdt_ws\jdt.1s-java-project\bin' 'SeasonsSwitch' Enter a date (String, int): September 67 September67 falls under Summer PS C:\Users\14848> HH | ? ! Launch Seasons IA XI Ln 15, Col 10 Spaces: 4 68F 08 UTF-8 CRLF I x tv ^ x Run: Seasons Run: Season... Run: Season... Run: Season... Run: Season... Run: Season... Run: Season... {} Java 4:50 PM 9/11/2022

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions