Ive been stuck on this problem for a while. any advice would be appreciated. Write a program...

80.2K

Verified Solution

Question

Programming

Ive been stuck on this problem for a while. any advice would beappreciated.

Write a program that takes a date as input and outputs thedate's season. The input is a string to represent the month and anint to represent the day.

Ex: If the input is: April 11

the output is: Spring

In addition, check if the string and int are valid (an actualmonth and day).

Ex: If the input is: Blue 65

The dates for each season are:
Spring: March 20 - June 20
Summer: June 21 - September 21
Autumn: September 22 - December 20
Winter: December 21 - March 19

this is what i have so far, its LONG but ive gone through thiswith a fine toothed comb and nothing works for me.

import java.util.Scanner;

public class LabProgram {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

String inputMonth = sc.next();

int inputDay = sc.nextInt();

{

if (inputMonth.equals(\"December\") && inputDay >= 21&& inputDay <= 31){

System.out.println(\"Winter\");}

else if (inputMonth.equals(\"January\") && inputDay >=1 && inputDay <= 31){

System.out.println(\"Winter\");}

else if (inputMonth.equals(\"February\") && inputDay >=1 && inputDay <= 29)

System.out.println(\"Winter\");

else if (inputMonth.equals(\"March\") && inputDay >= 1&& inputDay <= 19)

System.out.println(\"Winter\");

else if (inputMonth.equals(\"March\") && inputDay >= 20&& inputDay <= 31)

System.out.println(\"Spring\");

else if (inputMonth.equals(\"April\") && inputDay >= 1&& inputDay <= 30)

System.out.println(\"Spring\");

else if (inputMonth.equals(\"May\") && inputDay >= 1&& inputDay <= 29)

System.out.println(\"Spring\");

else if (inputMonth.equals(\"June\") && inputDay >= 1&& inputDay <= 20)

System.out.println(\"Summer\");

else if (inputMonth.equals(\"June\") && inputDay >= 21&& inputDay <= 30)

System.out.println(\"Summer\");

else if (inputMonth.equals(\"july\") && inputDay >= 1&& inputDay <= 29)

System.out.println(\"Summer\");

else if (inputMonth.equals(\"August\") && inputDay >= 1&& inputDay <= 29)

System.out.println(\"Summer\");

else if (inputMonth.equals(\"September\") && inputDay>= 1 && inputDay <= 21)

System.out.println(\"Summer\");

else if (inputMonth.equals(\"September\") && inputDay>= 21 && inputDay <= 29)

System.out.println(\"Autumn\");

else if (inputMonth.equals(\"October\") && inputDay >=1 && inputDay <= 31)

System.out.println(\"Autumn\");

else if (inputMonth.equals(\"November\") && inputDay >=1 && inputDay <= 29)

System.out.println(\"Autumn\");

else if (inputMonth.equals(\"December\") && inputDay >=1 && inputDay <= 20)

System.out.println(\"Autumn\");

}

else{

System.out.println(\"Invalid\");

{

thank you.

Answer & Explanation Solved by verified expert
4.4 Ratings (656 Votes)
SOLUTIONI have corrected your code and gave it below with screenshotActually in yr code there is before if    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students