This program will ask a user to enter their favorite color. Your program will tell the user what their “spirit animal” is based on the color entered. (Or you can do something similar but different – like online quizzes that tell you what kind of potato you are.) You will create a static method called getAnimal that takes in a single String and returns a String. In this method, you will write the code that will determine which animal gets returned. You may choose the possible colors and animals (or you may choose something else ridiculous for this program) but you must have at least 4 options for the user. For example, if they enter “red”, you might return “Tiger”. Make sure to include a response for incorrect inputs. In the main method you will give the program explanation, ask for input (favorite color), capture the input, call the getAnimal method (passing in the user’s input), and print the result. No try/catch blocks or loops are necessary. The static method should contain no print statements or requests for user input. It’s only task is to determine which animal string should be returned based on the user’s number.   Example:   What is your favorite color? (Select from red, green, blue, yellow, or black) I will tell you what your animal is.   >>>red   Tiger   ****************************************************************   What is your favorite color? (Select from red, green, blue, yellow, or black) I will tell you what your animal is.   >>>YELLOW   Does not compute.     in java

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
  1. This program will ask a user to enter their favorite color. Your program will tell the user what their “spirit animal” is based on the color entered. (Or you can do something similar but different – like online quizzes that tell you what kind of potato you are.)

  2. You will create a static method called getAnimal that takes in a single String and returns a String. In this method, you will write the code that will determine which animal gets returned. You may choose the possible colors and animals (or you may choose something else ridiculous for this program) but you must have at least 4 options for the user. For example, if they enter “red”, you might return “Tiger”. Make sure to include a response for incorrect inputs.

  3. In the main method you will give the program explanation, ask for input (favorite color), capture the input, call the getAnimal method (passing in the user’s input), and print the result.

  4. No try/catch blocks or loops are necessary.

  5. The static method should contain no print statements or requests for user input. It’s only task is to determine which animal string should be returned based on the user’s number.

 

Example:

 

What is your favorite color? (Select from red, green, blue, yellow, or black) I will tell you what your animal is.

 

>>>red

 

Tiger

 

****************************************************************

 

What is your favorite color? (Select from red, green, blue, yellow, or black) I will tell you what your animal is.

 

>>>YELLOW

 

Does not compute.

 

 

in java

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,