Advertisement
veronikaaa86

03. Animal Type

Mar 12th, 2022
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. package advancedConditionalStatements;
  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. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement