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
Plzz helps me with hw
IceJOKER [234]

Answer:

1. not statistical

2. statistical

3. statistical

4. not statistical

5. statistical

6. not statistical

7. statistical

Explanation:

The statistical can compare more then 1 thing to make it reasonable.

4 0
4 years ago
research the internet and develop a list of three important rules/standards you will give to the team to help everyone easily fi
natima [27]
The three important rules/standards that I can give to the team to help everyone easily find the documents in the future are the following:
1. Develop naming convention on how to define filename/documents.
2. All changes in the documents must be well documented, there should be a record of changes.
3.There must be a defined standard procedures on how to save and access the file, and who are allowed to modify the documents.
6 0
4 years ago
Buying an existing business
HACTEHA [7]
Goin to make great profit
8 0
3 years ago
What do all social media sites have in common? (Must check all that apply)
Georgia [21]
* <span>They all engage users with fun or interesting features.
*</span><span>They encourage people to participate.</span>
3 0
3 years ago
Subtract B8 from the sum of cells<br> C1 through C10
alina1380 [7]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

To subtract B8 from the sum of cells  C1 through C10, you need to perform the following steps.

  • click on empty cell or C11.
  • In C11 write the formula, <em>=sum(C1:C10) </em>this formula calculates the sum of cells  C1 through C10, and store result in C11.
  • Now click on cell C12.      
  • Write formula  in C12 i.e. <u>=C11-B8 </u><em><u> </u></em>this formula subtract B8 from the sum of cells  C1 through C10 and store result in C12

4 0
3 years ago
Other questions:
  • If you delete a view, account administrators can recover the view using the "trash can" function within how many days?
    7·2 answers
  • What are the four principal services provided by S/MIME?
    11·1 answer
  • Google Apps are an example of​ ________. A. platform as a service​ (PaaS) B. software as a product​ (SaaP) C. platform as a prod
    7·1 answer
  • Stella likes using social networking websites. Which Netiquette practice should Stella follow?
    9·2 answers
  • PLS ANSWER ASAP!
    9·1 answer
  • My computer keeps on logging me out when i try to answer a question on brainly. Can somebody please explain why. And give a good
    12·2 answers
  • This week you will learn about basic code structure. The term structure, as it relates to programming, refers to the decisions y
    14·1 answer
  • Given an array of users, write a function, namesAndRoles that returns all of user's names and roles in a string with each value
    15·1 answer
  • All HTML5 webpages must begin with the HTML element _____.
    6·1 answer
  • Your friend Aria is complaining that programming seems too complicated. She says, “Why do we need things like sequence, selectio
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!