Advertisement
myrdok123

05. Month Printer

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