1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
DaniilM [7]
1 year ago
13

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
Computers and Technology
1 answer:
Nataliya [291]1 year ago
6 0

Answer:

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.

You might be interested in
The three Fs of product design are form, fit and
Rudiy27

Answer: Function

Explanation: <em>"Function is a criterion that is met when the part performs its stated purpose effectively and reliably. In an electronics product, for example, function can depend on the solid-state components used, the software or firmware, and quite often on the features of the electronics enclosure selected. Poorly placed or sized ports and misleading or missing labeling are two of the most common ways in which an enclosure can fail the function criterion."</em>

5 0
3 years ago
Read 2 more answers
Why is iot architecture important?
Harlamova29_29 [7]
They need to make sure your building is easy to move around in. Beyond the building itself, architecture and design can help bring balance to people's lives. ... Well-designed schools create better learning environments. Workplaces with good architecture experience higher productivity.
7 0
3 years ago
The user location is usually a city
castortr0y [4]
What do you mean but I think yes the user location is usually a city
4 0
2 years ago
Two ways that a deer depends on plants to survive
Nastasia [14]
Food and oxygen would be the answer
4 0
3 years ago
Read 2 more answers
Write structured pseudocode to show the following: when you are on time for work you have time to buy coffee
faltersainse [42]

Answer:

If( on_time == True) {

     print("Coffee")

} else {

    print("No Coffee")

}

Explanation:

Step 1 evaluate with a boolean variable if you are on time

If( on_time == True) {

Step 2 if true you have coffee

print("Coffee")

Step 3 if false you have not coffee

print("No Coffee")

3 0
3 years ago
Other questions:
  • You have been contracted by a local school to evaluate their computer labs for security threats. They are most worried about the
    6·1 answer
  • Which function in Spell Checker should Patrick use if he makes the same mistake frequently when typing emails?
    11·1 answer
  • Write an expression that evaluates to true if and only if the value of the integer variable workedOvertime is true.
    7·1 answer
  • Home communication involves controlling systems such as heating, cooling, and security.
    11·1 answer
  • Write a program in pascal to solve a quadratic equation
    12·1 answer
  • 次のうち、ビジネスレターに適したフォントとポイントサイズの選択はどれですか?<br> 私を助けてください!私はあなたを最高にブランコにします!
    12·2 answers
  • Plz help fast! will mark brainliest!<br><br>List three ways that music is used in modern society.
    6·1 answer
  • Ayuda necesito 7 objetos que se utilizan en la vida diaria
    8·1 answer
  • Which of the following is not a key component of a structure?
    12·1 answer
  • Which three techniques are used in this photo
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!