joseleonweb

Untitled

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