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
A marketing firm has been hired to help a client understand how their online brand is perceived. The firm has set up a system to
KiRa [710]

Answer:

Automated Reasoning

Explanation:

Automated reasoning is a type of Natural language understanding(NLP) in computer science that makes logical inferences based on information or data previously gathered. Automated reasoning allows computers make intelligent decisions and reason logically based on data gathered. For example, a system is based to scan online reviews and conclude on the ones that are negative reactions based on previous data.

3 0
3 years ago
Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a pr
klio [65]

Answer:

See the code snippet below

Explanation:

import java.util.Scanner;

public class LabProgram{

     public static void main(String[] args){

          Scanner scan = new Scanner(System.in);

          System.out.println("Please enter first number: ");

          int firstNumber = scan.nextInt();

          System.out.println("Please enter second number: ");

          int secondNumber = scan.nextInt();

          maxMagnitude(firstNumber, secondNumber);

}

     public static int maxMagnitude(int firstValue, secondValue){

         System.out.println(Math.max(firstValue, secondValue));

}

}

6 0
3 years ago
True or false? you should avoid using your power point slides as handouts, according to the text.
vazorg [7]
True, you should avoid using power point notes always
4 0
2 years ago
-What does VI indicate when talking about LabView?
BaLLatris [955]

Answer:

The VI in LabView indicates c-Virtual Instrument

Explanation:

The VI in LabView is a program-subroutine. The VI stands for Virtual Instrument. The VI is composed of a Block diagram, Connector panel and a Front Panel.

4 0
3 years ago
Which design principle is the subject of a photo or image? ​
VashaNatasha [74]

The focal point is where the eye is drawn to in a photo or image.

6 0
3 years ago
Other questions:
  • When you create a new slide in a presentation program, you are promoted to choose a placeholder. True or false?
    11·2 answers
  • A company needs to store its documents in one place, share news and information with all staff, and allow access for employees w
    7·2 answers
  • What do vector handles point at?
    13·2 answers
  • True or false? A medical assistant can check for available exam rooms and providers using an electronic scheduling system.
    8·1 answer
  • Using the notation exemplified in following question , list a set of tables and attributes (and identify keys) to represent the
    10·1 answer
  • Which of these best represents a call to action?
    7·2 answers
  • In this section of your final project, you will write a basic script to create and back up files. You will create this script wi
    11·2 answers
  • Final one bit l y links are a virus that will corrupt your files do not go on it
    15·2 answers
  • Write a description of the photograph to someone who cannot see the photograph. Be sure to include the title of the photograph a
    5·1 answer
  • Which tab should a user click to access the Page Borders feature of Word?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!