Advertisement
Guest User

if and switch

a guest
May 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Kita2 {
  4.     public static void main(String[] args) {
  5.         System.out.println("enter the day in number:");
  6.         Scanner s = new Scanner(System.in);
  7.         int day = s.nextInt();
  8.  
  9.         /* the if style
  10.             if (s==3)
  11.             {
  12.                 System.out.println("Free day");
  13.             }
  14.             else if (s>=1 || s<=5)
  15.             {
  16.                 System.out.println("working day");
  17.             }
  18.             else if (s>=6 && s<=7)
  19.             {
  20.                 System.out.println("free day");
  21.             }
  22.             else
  23.             {
  24.                 System.out.println("WTF?!?!?!?");
  25.             }
  26.          */
  27.  
  28.         switch (day) {
  29.             case 1:
  30.             case 2:
  31.             case 4:
  32.             case 5:
  33.                 System.out.println("working day");
  34.                 break;
  35.             case 3:
  36.             case 6:
  37.             case 7:
  38.                 System.out.println("free day");
  39.                 break;
  40.             default:
  41.                 System.out.println("WTF?!?!?");
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement