Advertisement
veronikaaa86

03. Animal Type

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