HarrJ

Day 08 pm

Jun 27th, 2024
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Day08A {
  4.     public static void main(String[] args) {
  5.         Scanner uInput = new Scanner(System.in);
  6.         int totalMonthday;
  7.         String monthName;
  8.        
  9.         System.out.print("Enter month: ");
  10.         monthName = uInput.nextLine();
  11.        
  12.         switch (monthName.toLowerCase()) {
  13.             case "january":
  14.             case "march":
  15.             case "may":
  16.             case "july":
  17.             case "august":
  18.             case "october":
  19.             case "december":
  20.                 totalMonthday = 31;
  21.                 break;
  22.             case "april":
  23.             case "june":
  24.             case "september":
  25.             case "november":
  26.                 totalMonthday = 30;
  27.                 break;
  28.             case "february":
  29.                 totalMonthday = 28;
  30.                 break;
  31.             default:
  32.                 System.out.println("Not a valid month. Please try again");
  33.                 break;
  34.         }
  35.        
  36.         System.out.println(monthName + " have " + totalMonthday + " days");
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment