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
viktelen [127]
4 years ago
9

Tiffany is writing a program to help manage a bake sale. She writes the following code which prompts the user to enter the total

number of items a person is buying and then a loop repeatedly prompts for the cost of each item. She wrote the code but there is a problem: it runs in an infinite loop. How can Tiffany change her code so it doesn't loop forever?
0 var numItems = promptNum("How many items?");
1 var total = 0;
2 while (numItems > 0){
3 total = total + promptNum("Enter next item price");
4 }
5 console.log("The total is" + total);
Computers and Technology
1 answer:
Gekata [30.6K]4 years ago
3 0

Answer:

Add the line numItems=numItems-1 after the 3rd code line.

Explanation:

As the loop is not terminating thus the counter is to be added such that the value is decreased in each iteration. As the last item is entered the value will become 0. Now when the loop will again reach the while point, the condition will become false and thus the loop will be terminated.

You might be interested in
In cell K10, create a formula using the SUM function that calculated the total of the range F17:F20 subtracts it from the value
bogdanovich [222]

Answer:

Cell K10

=SUM(F17:F20 - J10 + G17:G20 - 160)

3 0
3 years ago
Can you recover deleted bookmarks on a Chromebook? If so, how?
torisob [31]
I believe not sorry pal :/
4 0
3 years ago
Read 2 more answers
How is communication within healthcare different than communication within other industries ?
vfiekz [6]

Answer:

It has to be more specific and easier to understand because of its importance.

Explanation:

7 0
4 years ago
Modify the program so that it can do any prescribed number of multiplication operations (at least up to 25 pairs). The program s
Anestetic [448]

Answer:

Im trying to prove to my parents that im smart.. so.. its 2.7! :D

Explanation:

4 0
4 years ago
When you download a file from the internet where should you go to find it?.
Gnom [1K]

Answer:

your downloads

Explanation:

6 0
2 years ago
Other questions:
  • Makes it possible to distribute both power and data using ethernet cabling. select one:
    12·1 answer
  • What feature is available to add a suggestion in the margin of someone else's document?
    7·1 answer
  • Which parts of the forebrain are sometimes described as the “executive center” and can be likened to the central processing unit
    9·1 answer
  • Whay device is recommended to use to install windows 10
    13·1 answer
  • Write a recursive method int power(int i, int j which determines teh result of i^j where j>=0
    6·1 answer
  • Which changes should be made to establish and maintain formal writing conventions? Select two options.
    10·1 answer
  • Write a program that prompts the user to enter two positive integers less than 1,000,000,000 and the program outputs the sum of
    15·1 answer
  • ________ include programs such as word processing, spreadsheet, database,presentation graphics. Personal information,
    6·1 answer
  • For risk monitoring, what are some techniques or tools you can implement in each of the seven domains of a typical IT infrastruc
    7·1 answer
  • Write a summary on the video "Greatest Inventions w/Bill Nye".
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!