Advertisement
joseleonweb

Untitled

Aug 21st, 2019
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HorariDeTreball {
  4.  
  5.   public static final int HORA_INICI = 9;
  6.  
  7.   public static final int HORA_FI = 17;
  8.  
  9.   public static void main (String[] args) {
  10.     Scanner lector = new Scanner(System.in);
  11.  
  12.     System.out.print("Quina hora és? ");
  13.     int hora = lector.nextInt();
  14.     lector.nextLine();
  15.  
  16.     if ((hora > 23)||(hora < 0)) {
  17.       System.out.println("L'hora és incorrecta.");
  18.     } else {
  19.       if ((hora >= HORA_INICI)&&(hora < HORA_FI)) {
  20.         System.out.println("Treball.");
  21.       } else {
  22.         System.out.println("Temps lliure.");
  23.       }
  24.     }
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement