aakash2310

time

Sep 23rd, 2022 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class time
  4. {
  5.      public static void main(String args[])
  6.      {
  7.             Scanner s = new Scanner(System.in);
  8.             System.out.println("Enter Time in hours : ");
  9.             int time = s.nextInt();
  10.        
  11.             if(time < 12 && time > 0)
  12.             {
  13.                 System.out.println("Good Morning" );
  14.             }
  15.             else if( time < 18 && time >= 12)
  16.             {
  17.                 System.out.println("Good Afternoon" );
  18.             }
  19.             else if( time < 24 && time >= 18)
  20.             {
  21.                 System.out.println("Good Night" );
  22.             }
  23.             else{
  24.                 System.out.println("ERROR");
  25.             }
  26.            
  27.          }
  28.                
  29.  }
Advertisement
Add Comment
Please, Sign In to add comment