Seasons on Terra

  • 4
An Earth year consists of four seasons, each of which lasts 3 months. While our ship was parked on this cradle of humanity, the Interplanetary Tax Service asked us to write a program to determine the season based on a number corresponding to the month of the year. We don't know why they want it. They say that it's none of our business. But they promised not to remain in our debt.
You can't complete this task, because you're not signed in.
Comments (24)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Karas Level 15, Tampa, United States
25 August 2020, 00:10
Just make sure you go all the way with the switch though... all of them 1 to 12.
Chase Level 17
17 August 2020, 04:14
When you don't get it on the first attempt because instead of putting autumn you put fall.
Chris Level 9, Newark, United States
29 July 2020, 18:50
I literally had to google conditional arguments because I only remembered the &&. When I mixed the || with the && I was able to output a correct answer in the console but the problem was still unresolved. Please help.
Roman Level 41
31 July 2020, 05:59
Please post your question with the attached solution in the section Help.
Marek Pasierbek Level 22, Poznań, Poland
10 June 2020, 09:20
use switch case
Chase Level 17
17 August 2020, 04:16
That would be way more code for somthing so simple. Just use operators such as && and || Much easier since we know that numbers can be within a specific range. One thing I have learned is to always take shortcuts if possible, and you should always try to avoid repeating code. A switch case would be repeating a lot of code in this instance.
Laurence Chadwell Level 7, San Antonio, United States
20 August 2019, 02:28
I went out side of the box on this one.....didn't even use if else statements.
Andrei Level 20
5 September 2020, 11:02
oh shit you went full matrix. would you mind sharing in private? thanks!
Brandon Nicolle Level 5, Edmonton, Canada
17 August 2019, 21:18
My code doesn't work for some reason. i thought using the || operator would make it easier? why is my else if statement not showing?
priss Level 18, Roosendaal, Netherlands
18 March 2020, 05:49
it does makes it easier ... use if and if else and but them in it corresponding to the months
Chase Level 17
17 August 2020, 04:19
When checking a range you need to use the && operator because the || operator is basically saying that it can be either of the conditions. When you use the && operator it has to be both those conditions. Hopefully that makes sense.
Andrei Level 20
5 September 2020, 11:03
Exactly, the || is not necessary in this excercise.. just if, else if and &&. :)
User Level 5, Shymkent, Kazakhstan
18 June 2019, 14:03
Help guys can't resolve lust Requirements Please help
Bipin kanani Level 11, Ahmedabad, India
13 June 2019, 13:42
try this way
Michael Martin Level 19, Arlington, United States
25 October 2018, 18:26
I'm just reviewing this course to see if it would be good for my son. I have a question on this section. This task requires knowledge of && or || for it to work, but I don't see where those concepts were covered in the lesson. Am I missing something?
Roman Level 41
26 October 2018, 05:50
You can solve this task without && or || .
Michael Martin Level 19, Arlington, United States
26 October 2018, 14:19
Yeah, after I asked that, I saw that it could be done. Sorry :)
24 June 2019, 17:51
can you tell me some tips that how can i run it without using && or || "\n" because i put it into questions all suggest me to use && or ||...... :{
24 June 2019, 17:52
how can you explain me ??? i did not get it
Roman Level 41
25 June 2019, 05:31
"switch" or "if ... else if" without && or ||
Muhammad Asad Level 9, Gujranwala, Pakistan
6 September 2018, 18:52
I cannot solve the problem please help me I have this code but i get errorpublic class Solution { public static void main(String[] args) { checkSeason(12); checkSeason(4); checkSeason(7); checkSeason(10); } public static void checkSeason(int month) { if(month>=3 && month<=5) { System.out.println("spring"); } else if(month>=6 && month<=8) { System.out.println("summer"); } else if(month>=9 && month<=11){ System.out.println("autumn"); }if(month==12 && month<=2) { System.out.println("winter"); } } }
Roman Level 41
7 September 2018, 05:50
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at
16 July 2019, 04:28
what was the solution for this?
Tomek Level 5, Torun, Poland
7 November 2019, 20:01
Look on your last if condition : (month==12 && month<=2) - that is impossible. Variable month can't has value 12 and less than 2 in the same time.