CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Start learning now
  • All questions
Igna P
Level 10
Copenhagen
  • 28.10.2019
  • 638views
  • 3comments

Why it doesn't compile?

Question about the task Seasons on Terra
Java Syntax,  Level 4,  Lesson 4
Resolved

Write the checkSeason method. Based on a number representing a month, the method should determine and display the season (winter, spring, summer, autumn).

Example for number 2:
winter

Example for number 5:
spring

Hint: the numbers 12, 1, and 2 are winter months; 3, 4, and 5 are spring, etc.

Requirements:
  • The program should display text on the screen.
  • The main method should not call System.out.println or System.out.print.
  • The main method must call the checkSeason method.
  • The checkSeason method must be static void, and have only one int parameter.
  • The checkSeason method should display text on the screen in accordance with the task conditions.
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) { if (month == 12 || month <= 2 ) { System.out.println("winter"); { else if (month >= 3 || month <=5) { System.out.println("spring"); } else if (month >= 6 || month <= 8) { System.out.println("summer"); } else { System.out.println("autumn"); } } }
0
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Anthony Chalk
Level 30 , London, United Kingdom
28 October 2019, 23:16
line 19, the { at the beginning of the line should be }
+2
Igna P
Level 10 , Copenhagen, Denmark
29 October 2019, 08:12
omg... silly mistake! Thank you so much!
0
Anthony Chalk
Level 30 , London, United Kingdom
29 October 2019, 10:55
the reason I picked up on it is because I make the same mistake myself the whole time :D
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.