subject

Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int 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 actual month and day).

Ex: If the input is invalid, the output is:

invalid
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

My code is constantly outputting 'invalid, regardless of the date input.

import java. util. Scanner;

public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
String inputMonth;
int inputDay;

inputMonth = scnr. next();
inputDay = scnr. nextInt();
if((inputMonth=="March"&&in putDay>19)||inputMonth=="April"| |inputMonth=="May"||(inputMonth=="J une"&&inputDay<21))
{
System. out. println("spring");
}
else if((inputMonth=="June"&&inp utDay>20)||inputMonth=="July"||i nputMonth=="August"||(inputMonth==" September"&&inputDay<22) )
{
System. out. println("summer");
}
else if((inputMonth=="September"&&am p;inputDay>21)||inputMonth=="Oct ober"||inputMonth=="November"||(inp utMonth=="December"&&inputD ay<21))
{
System. out. println("autumn");
}
else if((inputMonth=="December"&& ;inputDay>20)||inputMonth=="Janu ary"||inputMonth=="February"||(inpu tMonth=="March"&&inputDay&l t;20))
{
System. out. println("winter");
}
else
{
System. out. println("invalid");

} }
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:30
Jenny wants to look at row 345 and compare it to row 17. what can she do if she wanted to easily adjust to see both at once?
Answers: 3
question
Computers and Technology, 23.06.2019 21:40
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
Answers: 2
question
Computers and Technology, 24.06.2019 00:30
The best definition of an idiom is a. a word or phrase that describes a noun b. a word or phrase describing a verb c. a phrase containing figurative language in which the word expresses a different idea from its exact meaning d. a phrase that compares two unlike objects or ideas
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
What is the most important for you to choose before you build a network?
Answers: 1
You know the right answer?
Write a program that takes a date as input and outputs the date's season. The input is a string to r...
Questions
question
Mathematics, 24.11.2020 05:30
question
English, 24.11.2020 05:30
question
Social Studies, 24.11.2020 05:30
question
English, 24.11.2020 05:30
Questions on the website: 13722359