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]
4 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]4 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
The NFiPA 704 system uses a numerical value between _____ and _____ to indicate the level of hazard for that particular chemical
Lena [83]

d would be your answer....................................

3 0
3 years ago
Read 2 more answers
A plan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedul
vesna_86 [32]

Answer:

A study routine

Explanation:

6 0
3 years ago
Read 2 more answers
Question 7 * What is the default powerpoint standard layout A Blank B Title slide C Title only D. Comparison ​
lesantik [10]

Answer:

B. <u>Title</u><u> </u><u>slide</u><u> </u>layout is the default PowerPoint standard layout.

3 0
2 years ago
A married man gets a new job in a company. After three months, he meets a younger woman in the finance department and they begin
pav-90 [236]

Answer:

False ( B )

Explanation:

Of  the seven IT  infrastructure domains The USER domain was not at risk because the User Domain is not task with handling the sharing of data or Mutual communication between users in a Typical IT infrastructure.

The domain charged with such responsibility is The LAN domain because the LAN domain is charged with the sharing of information between the USERS and maintaining good mutual communication, and since the relationship has become sour, the sharing of information between the users will suffer the most and it will be at a high risk

5 0
3 years ago
Why do we install doorbells in our house
Vinil7 [7]

Explanation:

It's placed near the door. When a visitor presses the button, the bell rings inside alerting you that someone is at the door.

6 0
3 years ago
Read 2 more answers
Other questions:
  • What are Three types of informational references
    9·2 answers
  • A right turn should be from the right lane into the right lane of the roadway entered. True or false. A. True B. False
    11·1 answer
  • A network administrator receives a call from the sales department requesting ports 20 and 21 be opened on the company’s firewall
    12·1 answer
  • As Alexa types a message, Outlook autosaves the message at various points. In which folder is the message located if Alexa wants
    15·2 answers
  • Which statement in switch case structure transfers the control flow outside the structure? switch statement break statement case
    5·2 answers
  • Describe a common error that presenters make during their presentation and how to remedy the error​
    12·2 answers
  • In cell B3, insert a nested MATCH function within an INDEX function that will look up the rental price in column D using the apa
    15·1 answer
  • 2. The<br>is the main and usually largest data storage hardware device in a computer​
    9·1 answer
  • Please help ASAP !!!
    15·1 answer
  • The CUBE extension enables you to get a subtotal for each column listed in the expression, in addition to a grand total for the
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!