// The system passes the code, but I am wondering if there is a smarter solution
// I tried to use ||, but seems it only works or the binary "a or b" case, but not for "a or b or c" case
package com.codegym.task.task04.task0411;
/*
Seasons on Terra
*/
public class Solution {
public static void main(String[] args) {
checkSeason(12);
checkSeason(4);
checkSeason(7);
checkSeason(10);
}
public static void checkSeason(int month) {
//write your code here
if (month == 12)
System.out.println("winter");
if (month == 1)
System.out.println("winter");
if (month == 2)
System.out.println("winter");
if (month == 3)
System.out.println("spring");
if (month == 4)
System.out.println("spring");
if (month == 5)
System.out.println("spring");
if (month == 6)
System.out.println("summer");
if (month == 7)
System.out.println("summer");
if (month == 8)
System.out.println("summer");
if (month == 9)
System.out.println("autumn");
if (month == 10)
System.out.println("autumn");
if (month == 11)
System.out.println("autumn");
}
}
// Thanks
Any smart solution?
Under discussion
Comments (6)
- Popular
- New
- Old
You must be signed in to leave a comment
Stephen Haokip
16 November 2020, 16:46
i have a dumber solution
0
Drazen Jankovic
16 November 2020, 12:05
I would also said, that the switch case is the best solution for this task, but it's also important to implement what are we learning at this level... Switch will do anyway soon 😀
0
Nouser
16 November 2020, 07:36
switch-case will work, too
+2
Vincenzo Seggio
16 November 2020, 07:02
Yes, with if - else if - Conditions.
Example for spring:
0
Albert
16 November 2020, 07:15
Coole Idee, danke : )
0
Vincenzo Seggio
16 November 2020, 08:07
Kein Problem 👍
0