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
An administrator wants to configure hosts to automatically assign IPv6 addresses to themselves by the use of Router Advertisemen
Elza [17]

Answer:

The answer to this question is the option "B".

Explanation:

In this question the answer Stateless DHCPv6. It stands for (stateless Dynamic Host Configuration Protocol for IPv6). Where IPv6 stands for internet protocol version 6. The feature of the DHCPv6 is that it is used to configure a link or node with arguments. It does not use the server for managing any dynamic state for the node or links.  To configure hosts to automatically the administrator use the Stateless DHCPv6 .

6 0
3 years ago
If a user on a laptop complains that they are unable to sign into windows even though they are certain they are entering the cor
earnstyle [38]
Retry the username or email and password again if that dont work then they will have to change the password cause it seems that they have forgot it
6 0
3 years ago
What the five types of initiatives that are necessary when putting together and implementing an IT strategy
STatiana [176]

Answer:

Pre-implementation

Planning

Execution

Completion

Control

Explanation:

The pre-implementation stage speaks volumes on the breakdown of the implementation stages and how it is being formulated. It shows a stepwise identification of important implementation carriers and the responsibility of the IT organization. Their focus is to determine the content and human resources that are required to implement the strategy being formulated.

The purpose of the planning implementation stage is to plan and agree on specific goals by considering all stakeholders. There is also a need to set deadlines, time-to-time evaluation, and effective coordination of the stakeholders.

The execution phase enforces the implementation plan. As the name implies, it builds a comprehensive plan by focusing on the target group to maintain and ensure a structural and systematically conducted work environment.

The completion phase includes all actions necessary to bring out the results within the organizzation. Initially, there is a need to agree on the dimension of the IT strategy, the time dimension, and the detailed dimension.

The last phase which is the control deals with the logic of setting appropriate quantitative and qualitative control measures so as to allows continuous implementation control and navigation implementation control.

7 0
3 years ago
Write code using the range function to add up the series 20, 30, 40, ... 90 and print the resulting sum each step along the way.
andrew11 [14]

Answer:I DK but if you expaln it I can help. Sorry.

Explanation:

3 0
3 years ago
Write a MATLAB script using the quiver and contour commands to visualize the field and its divergence. Assume the region of inte
DochEvi [55]

Answer:

2b2t

Explanation:

2b2t

4 0
3 years ago
Other questions:
  • Inkjet printers and laser printers are examples of ________ printers. (1 point)
    13·1 answer
  • The narrative structure of the popular movies can be broken down into
    15·1 answer
  • What is the Documenter?
    10·1 answer
  • Which statements are true about modern
    9·1 answer
  • A domain name is used to: *
    15·1 answer
  • Explain the procedure you will undertake to create a new partition​
    11·1 answer
  • Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6
    6·1 answer
  • The kinetoscope is ___________________ a. a disk with a series of drawings around the edge, showing the same object in slightly
    9·2 answers
  • Which of the following is a software tool used to manage data for a project in a logical and hierarchical order?
    13·1 answer
  • What is the difference between a free-form outline and a modified outline?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!