Advertisement
Spocoman

01. Day of Week

Oct 20th, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int day = Integer.parseInt(scanner.nextLine());
  7.        
  8.         String[] week = {
  9.             "Monday",
  10.             "Tuesday",
  11.             "Wednesday",
  12.             "Thursday",
  13.             "Friday",
  14.             "Saturday",
  15.             "Sunday"
  16.            
  17.         };
  18.        
  19.         if (day > 0 && day < 8) {
  20.             System.out.println(week[day - 1]);
  21.         } else {
  22.             System.out.println("Invalid day!");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement