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
loris [4]
3 years ago
5

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?line 0 -- var numItems = promptNum("How many items?");line 1-- var total = 0;line 2-- while (numItems > 0){line 3-- total = total + promptNum("Enter next item price");line4-- }line 5-- console.log("The total is" + total);A) Change Line 1 to:var total = -1;B) Change Line 2 to:while (itemsInCart >= 0){C) Change Line 3 to:total = promptNum("Enter next item price");D) Add after line 3:numItems = numItems - 1;E) Add after line 4:numItems = 0;
Computers and Technology
1 answer:
Katyanochek1 [597]3 years ago
8 0

Answer:

Option D is the correct answer for the above question.

Explanation:

  • The above question code executes the infinite while loop because there is no operation in the loop body which helps the loop condition to be false in any iteration of the while loop.
  • Every while loop contains the three thinks, one is starting value for the loop, the second is a condition which states that the body of the loop will execute or not and the third is an operation which states the condition variable to be false or true.
  • The above program has only two think the starting value which is given by the user in numItems variables and the condition check which decides that the value entered should be greater than 0.
  • So to states, the condition will false there needs some increment operation which states the condition variable will be false. So there must be an operation for "numItems" variables because it participates in the condition of the while loop.
  • The operation relates to the "numItems" variable is given only in option D. Hence D is the correct option while the other is not because others do not hold the operation for "numItems" variables.
You might be interested in
What is the difference between Packaged and tailored soft ware?​
Rainbow [258]

Answer:

<em>Package software is developed by computer technicians. modified or changed if there is need because these software are custom-built. Tailored Software- Tailored software is the software that is developed as per the specifications and requirements of the users.</em>

Explanation:

hpithlps.

4 0
3 years ago
Which number is equivalent to 3e-2?<br><br> 30<br><br> 0.03<br><br> 0.3<br><br> 3
nevsk [136]

Answer:

0.03

Explanation:

3e-2 is in scientific notation, also known as standard form. Used to write large or small numbers in another way. In the number 3e-2, the numbers are defined as follows:

3 = coefficient

e = 10 to the power of

-2 = exponent

The scientific notation 3e-2 is same as 3 x 10^-2 or 3 x 10-2. Thus, to get the answer to 3e-2 as a decimal, we multiply 3 by 10 to the power of -2.

= 3e-2

= 3 × 10-2

= 0.03

3 0
2 years ago
Place Letter or word in correct section where it says labels bellow
love history [14]
A beauty its not b c or d
3 0
3 years ago
Read 2 more answers
Where Can I Get Actual Microsoft AZ-900 Exam Questions?
Pachacha [2.7K]

Answer:

Pls check the site "examtopics"

U fill find ur questions there

8 0
4 years ago
You've found an image you want to insert into your slide presentation. You
user100 [1]
You would need to adjust the hue
5 0
4 years ago
Read 2 more answers
Other questions:
  • using unsafe sites may be a. harmful to your computer c. okay as long as you don���t leave any personal information b. okay as l
    9·2 answers
  • What are 3 characteristics of syndrome E?
    13·1 answer
  • In what way, if any, are colleges and universities related?
    14·1 answer
  • What should you do if a dialog box covers an area of the screen that you need to see?
    10·2 answers
  • Which type of address is used at the transport layer to identify the receiving application?
    14·1 answer
  • This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
    7·1 answer
  • 12. Realizar un algoritmo que genere un número aleatorio, el usuario debe adivinar cual es el número generado para esto tendrá 3
    10·1 answer
  • Object-Oriented Programming (Using Java Language)
    11·1 answer
  • Who is responsible for developing the physical background for the characters by creating buildings, landscapes, and interiors?
    14·1 answer
  • Weaknesses about ICT Technician
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!