Advertisement
CoineTre

JF-Lab05. Month Printer

Jan 14th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MonthPrinter {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int input = Integer.parseInt(scanner.nextLine());
  7.         String month;
  8.         switch (input){
  9.             case 1:
  10.                 month = "January";
  11.                 break;
  12.             case 2:
  13.                 month = "February";
  14.                 break;
  15.             case 3:
  16.                 month = "March";
  17.                 break;
  18.             case 4:
  19.                 month = "April";
  20.                 break;
  21.             case 5:
  22.                 month = "May";
  23.                 break;
  24.             case 6:
  25.                 month = "June";
  26.                 break;
  27.             case 7:
  28.                 month = "July";
  29.                 break;
  30.             case 8:
  31.                 month = "August";
  32.                 break;
  33.             case 9:
  34.                 month = "September";
  35.                 break;
  36.             case 10:
  37.                 month = "October";
  38.                 break;
  39.             case 11:
  40.                 month = "November";
  41.                 break;
  42.             case 12:
  43.                 month = "December";
  44.                 break;
  45.             default:
  46.                 month = "Error!";
  47.         }
  48.         System.out.println(month);
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement