Xadez

Pets with else if

Apr 14th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Learning {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String pet = scanner.nextLine();
  8.  
  9.         if (pet.equalsIgnoreCase("dog")) {
  10.             System.out.println("mammal");
  11.         } else if (pet.equalsIgnoreCase("snake")){
  12.             System.out.println("reptile");
  13.         } else if (pet.equalsIgnoreCase("crocodile")){
  14.             System.out.println("reptile");
  15.         } else if (pet.equalsIgnoreCase("tortoise")){
  16.             System.out.println("reptile");
  17.         } else {
  18.             System.out.println("unknown");
  19.         }
  20.     }
  21. }
Add Comment
Please, Sign In to add comment