Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program plays a simple game, where it as ks the player about their dog, and

ID: 3888796 • Letter: T

Question

This program plays a simple game, where it as

ks the player about their dog,

and attempts to guess

the dog’s breed based on their answers. For

simplicity’s sake, there are only five possible dog breeds.

(

WARNING

: This part of the homework is the most challenging, so budget

plenty of time and brain p

ower. And read the instructions carefully!)

The program can ask the player about four characteristics. It should ask the

minimum

number of questions needed to guess the dog’s breed.

(HINT: It should need to ask

no less

than two questions and

no more

tha

n

three questions to find the right breed.)

Do the dog’s ears stick up

?

Does

the dog come in multiple colors

?

Can the dog bark

?

Does the dog have a curly tail?

For these inputs, the program can assume the following:

The user will only ever enter either lo

wercase

y

es

(for “yes”)

or lowercase

n

o

(for “no”)

Based on the user’s responses, the program must select the correct breed

and print it to the screen. Here are the possibilities for the dog breeds:

Dog has a curly tail and can bark:

Eurasier

Dog has a

curly tail and

cannot

bark:

Basenji

Dog does

not

have a curly tail and its ears stick up:

Pharaoh Hound

Dog does

not

have a curly tail, its ears do

not

stick up, and it does

come in multiple colors:

Chesapeake Bay Retriever

Dog does

not

have a curly tail,

its ears do

not

stick up, and it does

not

come in multiple colors:

Maremma Sheepdog

Explanation / Answer

import java.io.*
class GuessDog
{
public static void main(String args[ ]) throws IOException
{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String barks,curly_tail,multiple_color,ear_stickup;

System.out.println("Can dog bark?");
barks=br.readLine();
if(barks=="yes")
{
   System.out.println("Does it has a curly tail?");
    curly_tail=br.readLine();
   if(curly_tail=="yes")
   {
       System.out.println("Eurasier Dog");
   }
   else
   System.out.println("Does its ear stick up?");
   ear_stickup=br.readLine();
   if(ear_stickup=="yes")
       System.out.println("Pharaoh Hound Dog");
   else
   {
   System.out.println("Does it comes in multiple colors?");
   multiple_color=br.readLine();
   if(multiple_color="yes")
       Syetm.out.println("Chesapeake Bay Retriever");
   Syetm.out.println("Maremma Sheepdog");
   }
}
   Syetm.out.println("Basenji Dog");
}
}
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote