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
Arte-miy333 [17]
3 years ago
15

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);
Add after line 3: numItems = numItems - 1;

What value will be displaye
Computers and Technology
1 answer:
PtichkaEL [24]3 years ago
8 0

Answer:

Explanation:

the answer is also in the question. The loop is used to control the number of  program execution. So in order not to run forever, the loop should be included inside the loop brackets. Then you can restructure the code as done below.

var numItems = promptNum("How many items?");

var total = 0;

var itemPrice=0;

while (numItems > 0){

itemPrice = promptNum("Enter next item price");

total = total + itemPrice;

numItems = numItems - 1;

}

console.log("The total is" + total);

The value to be displayed will be the total of the item prices inputted.

You might be interested in
Ports that expand the options for input, output, and storage, are commonly called ____________ ports.
Ostrovityanka [42]
The answer is expansion ports
5 0
3 years ago
TRUE OR FALSE! A query can have no more than three common interpretations.
Vanyuwa [196]

A query can have no more than three common interpretations is false. A query is a search through a source to find the answer to something. A common interpretation are the items that pop up in in the first spots of the search query because they are the most relatable to the question. A common interpretation usually answers the question, but there are times that the question is more complex and needs to be search for longer within the sources that pop up.

8 0
3 years ago
. Mercury, Venus, Earth, and Mars are the closest planets to the Sun
DIA [1.3K]

Answer:

<h3>True</h3><h2>Mercury  is the nearest</h2>

Explanation:

I hope this helps

4 0
3 years ago
Suppose we are sorting an array of nine integers using heapsort, and we have just finished one of the reheapifications downward.
Ilia_Sergeevich [38]

Answer:

3

Explanation:

Heap sort pick an item from the first or last position in an array and compares it with other items in other positions in the array, swapping position if they meet the condition.

The array above has three maximum items arranged sequentially in the array, this is prove that there have been 3 reheapifications in the array.

7 0
3 years ago
Calculate the number of hours since the birthdate. Insert your calculation in cell C15. (hint: convert the number of days to num
Alik [6]

Answer:

Explanation:

To resolve this problem, first, we need the current date and a pass day, with these two values, we're going to use the formula called "DAYS" this formula returns the numbers of day between two dates, when we get the number of days, only we must multiply the result by 24, in this case, this represents the 24 hours in a day.

5 0
4 years ago
Other questions:
  • What is the difference between www vs internet in information technology?
    13·1 answer
  • In the blank LibreOffice Writer document, to start the process of entering a date field into a letter, click on the Insert menu.
    8·2 answers
  • Which option describes wearable technology?
    5·2 answers
  • Compose a program to examine the string "Hello, world!\n", and calculate the total decimal numeric value of all the characters i
    7·1 answer
  • Write pseudocode instructions to carry out each of the following computational operations:1. Determine the area of a triangle gi
    12·1 answer
  • You can copy a selected shape by holding down the ____ key and then dragging the shape.
    9·2 answers
  • The term integration mean?
    7·2 answers
  • HELP ME PLEASE ASAP
    6·1 answer
  • Windows hard disks can now use a variety of file systems, including FAT16, FAT32, ____, and Resilient File System.
    8·1 answer
  • Which THREE of the following actions can you perform with most webmail services?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!