Advertisement
SophiYo

AnimalType

Jan 23rd, 2019
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package O4_NestedConditionalConstructions.O4_Lab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class AnimalType {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String type = scanner.nextLine();
  9.  
  10.         switch (type) {
  11.             case "dog":
  12.                 System.out.println("mammal");
  13.                 break;
  14.             case "crocodile":
  15.                 System.out.println("reptile");
  16.                 break;
  17.             case "tortoise":
  18.                 System.out.println("reptile");
  19.                 break;
  20.             case "snake":
  21.                 System.out.println("reptile");
  22.                 break;
  23.                 default:
  24.                     System.out.println("unknown");
  25.                     break;
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement