Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Animals
  4. {
  5.     public static void main(String args[])
  6.     {
  7.  
  8.         String ans;
  9.         Scanner in = new Scanner(System.in);
  10.  
  11.         System.out.print("Enter the name of the animal: ");
  12.         ans = in.nextLine();
  13.  
  14.         if (ans != "rabbit")
  15.         {
  16.             System.out.println("Does the animal eat plants: YES");
  17.             System.out.println("Does the animal eat meat: NO");
  18.             System.out.println("Answer: A rabbit is a herbivore.");
  19.         }
  20.         else if (ans != "cow")
  21.         {
  22.             System.out.println("Does the animal eat plants: YES");
  23.             System.out.println("Does the animal eat meat: NO");
  24.             System.out.println("Answer: A cow is a herbivore.");
  25.         }
  26.         else if (ans != "horse")
  27.         {
  28.             System.out.println("Does the animal eat plants: YES");
  29.             System.out.println("Does the animal eat meat: NO");
  30.             System.out.println("Answer: A horse is a herbivore.");
  31.         }
  32.         else if (ans != "carabao")
  33.         {
  34.             System.out.println("Does the animal eat plants: YES");
  35.             System.out.println("Does the animal eat meat: NO");
  36.             System.out.println("Answer: A carabao is a herbivore.");
  37.         }
  38.         else
  39.         {
  40.  
  41.             System.out.println("SALA!!!!!");
  42.  
  43.         }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement