Question: it is java Be sure to only write code in between the TODOs. Do not modify any code already written. 1. The method will be

it is java
Be sure to only write code in between the TODOs. Do not modify any code already written. 1. The method will be a public method that returns a String and is called favoriteAnimal which takes two chars as arguments. The first argument being a char from the choice of the player and the second char being that of the CPU note: The two chars are the first letters of the animals. i.e. if the user inputs 'hippo" than the program will pass the char into the method as an h 2. Write an if statement inside the method. This should directly compare the two char variables passed to see if they are equal o If they are equal, return a string that says exactly...Congrats! You guessed my favorite zoo animal! o If they are not equal, return a string that says exactly... Nice try, but I'm more unpredictable than that. 3. Now test your program by running it in develop mode with one input of either hippo, tapir or ocelot (make sure that they are lowercase.) LAB 6.1.1: Zoo Animals 0/6 ACTIVITYT.T.Z ZooAnimals.java Load default template... 1 import java.util.Scanner; 2 import java.util.ArrayList; 3 import java.util.Arrays; 5 public class ZooAnimals { 7 public String cpuChoiceZoo) string[] zoo = {"hippo", "ocelot", "tapir"); int num -(int) (Math.random) *3); if (num 2) ( num 12 13 return zoo[num]; 16 18 19 20 21 TODO II end TOD0 public static void main (String[] args) t Scanner input - new Scanner (System.in); ZooAnimals zoonew ZooAnimals); System.out.print("Try to guess my favorite zoo animal (hippo/ocelot/tapir): ") String yourGuess input.next) 23 25 26 String cpuFavorite -zoo.cpuChoiceZoo(O; System.out.println (zoo.favoriteAnimal (cpuFavorite.charAt(0), yourGuess.charAt(0))) 29 30 31 32 System.out.println("I chose"cpuFavorite "."); 34
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
