Java Convert Numbers into Months


Ram is very weak in converting the numbers into months. But his friends often tease him by asking him to do that. To solve his problem a close friend of him, suggested meeting IIT students, who were very good at programming. Help ram to resolve his problem.

Note : 
Range of inputs is 1 to 12.
If the input given is beyond the range display error message as given in the sample output.

Sample Input 1:


Sample Output 1:


Sample Input 2:


Sample Output 2:

No month for the number 15

Code :-

import java.util.*;
public class NumToMonth
    public static void main (String[] args) {
        Scanner sc=new Scanner(;
        int n=sc.nextInt();
        String mon[]={"January", "February", "March","April", "May", "June", "July", "August", "September", "October", "November", "December"};
            System.out.println("No month for the number "+n);


  1. Find Season
  2. Lucky Number
  3. Pencil Count
  4. Repetition of a Number
  5. Bonus Points – Bike Race
  6. Celcius to Farenheit Conversion

1 thought on “Java Convert Numbers into Months”

Leave a Comment

Your email address will not be published. Required fields are marked *