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 09:30
Is a string of code written to hurt others by damaging or destroying
Answers: 1
question
Computers and Technology, 23.06.2019 00:10
Write a function so that the main0 code below can be replaced by the simpler code that calls function mphandminutes tomiles0. original main0 int main) l double milesperhour-70.0; double minutestraveled = 100.0; double hourstraveled; double milestraveled; hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; cout < "miles" 2 using namespace std; 4 /* your solution goes here/ 6 int maino 1 test passed 7 double milesperhour 70.0 all tests passed 8 double minutestraveled 100.0; 10 cout < < "miles: " < < mphandminutestomiles(milesper-hour, minutestraveled) < < endl; 12 return 0; 13
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
Whats three fourths of 15(this is supposed to be in math but i clicked too fast)
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
History, 16.10.2020 08:01
question
English, 16.10.2020 08:01
question
English, 16.10.2020 08:01
question
Computers and Technology, 16.10.2020 09:01