loading
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    System.out.println("\n\nLet's play 20 questions. Choose an animal and I will try to guess it!");
    Scanner scan = new Scanner(System.in);
  
    System.out.println("Is it a mammal (y/n)?");
    String answer = scan.nextLine();
    if (answer.equals("y")) {
      System.out.println("Is it a pet (y/n)?");
      answer = scan.nextLine();
      if (answer.equals("y")) {
           System.out.println("I guess a dog! Click on run to play again.");
       }
       else { 
           System.out.println("I guess an elephant! Click on run to play again.");   
       }
    }      
    else { // not a mammal
        System.out.println("I guess a bird! Click on run to play again.");
      }      
  

  }
}