desislava_topuzakova

03. Animal Type

Sep 25th, 2021
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AnimalType_03 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String animal = scanner.nextLine();
  7. //dog -> mammal
  8. //crocodile, tortoise, snake -> reptile
  9. //others -> unknown
  10. //серия от проверки за точни стойности на променливата animal
  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. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment