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.
Seasons on Terra
- 4
Locked
Comments (30)
- Popular
- New
- Old
You must be signed in to leave a comment
Lunita
5 February, 02:11
I used if with the || (OR) logical operator in my solution, and it passed at the first try!
+2
MrWaito
12 March, 17:18
Your hints are the best! Passed it at the first try too
0
Jomar TayactacExpert
20 July 2021, 16:49
I went with if/else-if way of solving this one which I think the simplest way.
0
Usman Full Stack Developer at QA
24 June 2021, 12:44
if using the switch statetment, dont forget the
+2
Karas Java Developer
25 August 2020, 00:10
Just make sure you go all the way with the switch though... all of them 1 to 12.
0
Chase
17 August 2020, 04:14
When you don't get it on the first attempt because instead of putting autumn you put fall.
+5
Chris
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.
+1
Roman
31 July 2020, 05:59
Please post your question with the attached solution in the section Help.
0
Marek Pasierbek Working at Nexus Polska
10 June 2020, 09:20
use switch case
+1
Chase
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.
+1
Usman Full Stack Developer at QA
24 June 2021, 12:48
I see whatt your saying about less code, however cleaner code > less more complex code. personally think switch looks cleanner and the better option here.
and no, you dont have to repeat code with switch. you can have multiple cases with the just one typed output if you utilize break;
0
Laurence Chadwell
20 August 2019, 02:28
I went out side of the box on this one.....didn't even use if else statements.
+1
Andrei
5 September 2020, 11:02
oh shit you went full matrix. would you mind sharing in private? thanks!
0
Brandon Nicolle
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?
+1
priss
18 March 2020, 05:49
it does makes it easier ... use if and if else and but them in it corresponding to the months
+1
Chase
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.
+1
Andrei
5 September 2020, 11:03
Exactly, the || is not necessary in this excercise.. just if, else if and &&. :)
0
User
18 June 2019, 14:03
Help guys
can't resolve lust Requirements
Please help
+1