Month number

  • 5
  • Locked
The time intervals "year" and "month", which have been adopted on Terra, are also used on other Federation planets and objects, including the CodeGym spaceship. But new extraterrestrial crew members are often confused by these earthly months. Let's help them: write a program that uses collections to display a number's month given its name.
You can't complete this task, because you're not signed in.
Comments (7)
  • Popular
  • New
  • Old
You must be signed in
maniLevel 13 , Harpanahalli
1 July, 10:07
please help me to find errors package com.codegym.task.task08.task0828; import; import; import; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /* Month number */ public class Solution { public static void main(String[] args) throws IOException { //write your code here ArrayList<String> s = new ArrayList<>(); s.add("january"); s.add("february"); s.add("march"); s.add("april"); s.add("may"); s.add("june"); s.add("July"); s.add("august"); s.add("september"); s.add("october"); s.add("november"); s.add("december"); BufferedReader reader = new BufferedReader(new InputStreamReader(; String m = reader.readLine(); String m1=m.toLowerCase(); //System.out.println(m1); int i= s.indexOf(m1); if(i!=-1) System.out.println(m+" is month "+(i+1)); } }
RomanLevel 41
2 July, 06:35
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
Davor KandicLevel 9 , Beograd
13 May, 14:54
Again in the task is given wrong example! Sentence that your program should display is without full-stop(.) !!!
RomanLevel 41
14 May, 06:40
Full-stop refers to the whole sentence. The full-stop in the output example would look like this: The program reads the name of the month from the keyboard and then displays its number on the screen in a phrase like: "May is month 5.".
Davor KandicLevel 9 , Beograd
14 May, 09:24
If displayed line should be "May is month 5" then in the conditions should NOT be "May is month 5." , because it is logical that whatever is between quotation marks is part of string. So, this will generate error when verify: System.out.println(input + " is month " + num + "."); And this will pass verification: System.out.println(input + " is month " + num); And it is not obvious from conditions text.
RomanLevel 41
15 May, 06:38
The full-stop is situated after the quotation mark, it does not belong to the output! The program reads the name of the month from the keyboard and then displays its number on the screen in a phrase like: "<output>". <output> = May is month 5 (w/o full-stop!)
Davor KandicLevel 9 , Beograd
16 May, 22:10
Indeed it is. Now I see it! But I was sure that I saw inside quotations marks. I am sorry, I was wrong. That's because of a lot staring into the screen, I suppose. Sorry, my mistake.