Write a loop that continually asks the user what pets the user has until the user enters stop, in which case the loop ends. It s
hould acknowledge the user in the following format. For the first pet, it should say You have one cat. Total # of Pets: 1 if they enter cat, and so on. Sample Run
What pet do you have? lemur
What pet do you have? parrot
What pet do you have? cat
What pet do you have? stop
Sample Output
What pet do you have? lemur
You have one lemur. Total # of Pets: 1
What pet do you have? parrot
You have one parrot. Total # of Pets: 2
What pet do you have? cat
You have one cat. Total # of Pets: 3
What pet do you have? stop
int counter = 0; String userInput = ""; while (userInput != "stop") { print "What pet do you have? "; userInput = readInputLine(); if (userInput != "stop" ){ counter = counter + 1; print "\nYou have one "; print userInput; print ". Total # of Pets: "; print counter; } }
Explanation:
not sure what programming language you use, therefore the answer is pseudocode but it should give you an idea how to implement a piece of code for this problem. Also, from the way you described the exercise I'm not sure if you always are supposed to reply with "you have one" + the pet or if you should count how often the same pet was entered.
Usually you can just report the question as useless or just report in in general. But I myself have read some answers and they dont even pertain to the question, it confuses me alot