veronikaaa86

03. Animal Type

Mar 22nd, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. package conditionalStatementsAdvanced;
  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. String type = "";
  12. switch (animal) {
  13. case "dog":
  14. type = "mammal";
  15. break;
  16. case "crocodile":
  17. case "tortoise":
  18. case "snake":
  19. type = "reptile";
  20. break;
  21. default:
  22. type = "unknown";
  23. break;
  24. }
  25.  
  26. System.out.println(type);
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment