Didart

Month Printer

Sep 16th, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package src;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class MonthPrinter {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int month = Integer.parseInt(scanner.nextLine());
  10.  
  11.         switch (month) {
  12.             case 1 -> System.out.println("January");
  13.             case 2 -> System.out.println("February");
  14.             case 3 -> System.out.println("March");
  15.             case 4 -> System.out.println("April");
  16.             case 5 -> System.out.println("May");
  17.             case 6 -> System.out.println("June");
  18.             case 7 -> System.out.println("July");
  19.             case 8 -> System.out.println("August");
  20.             case 9 -> System.out.println("September");
  21.             case 10 -> System.out.println("October");
  22.             case 11 -> System.out.println("November");
  23.             case 12 -> System.out.println("December");
  24.             default -> System.out.println("Error!");
  25.         }
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment