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 most widely used operating system for mobile devices?
Alekssandra [29.7K]
Android, many phone brands use the Android OS. Unlike Apple, which is the only technology company with IOS.
8 0
3 years ago
A user complains because the social media apps on his mobile device always note his location. The user is worried about privacy,
stich3 [128]

Answer:

Geotracking feature needs to be adjusted.

Explanation:

5 0
3 years ago
1) Draw an activity diagram according to the below flow of event:
stiv31 [10]

Answer:

Yyyyttttrrttyuynynnyj6jj

6 0
3 years ago
In a construction company, a new system has been in place for a few months and now there is a list of possible changes/updates t
Vitek1552 [10]

Answer:

A) corrective.

B) adaptive.

C) perfective.

Explanation:

Making changes due to an error is corrective, making changes in order to be able to accommodate new methods is adaptive, and changes in strict adherence to regulations must be perfective.

8 0
3 years ago
How to unblock a website on a school computer? ASAP who's ever works will get Brainliest and will get a follow.
Angelina_Jolie [31]

Answer:

You can't unblock them without admin access to the router. The only way to visit such sites is to find a VPN that is not also blocked by the school.

But you should know, what you are trying to do can get you in trouble if the school's IT department is competent to any extent.

4 0
3 years ago
Read 2 more answers
Other questions:
  • In the electric series, which one of the following materials is the most negatively charged? A. Silk B. Sealing wax C. Teflon D.
    7·2 answers
  • Constructors ________. initialize instance variables when overloaded, can have identical argument lists when overloaded, are sel
    11·1 answer
  • The Caesar Cipher has 25 different shifts to try.
    14·1 answer
  • The GaVS resource where students can locate information regarding Canvas, student email, registration and O365 is called the: St
    6·1 answer
  • What is the purpose of the overload keyword in the ip nat inside source list 1 pool nat_pool overload command?
    8·1 answer
  • . If you have written the following source code:
    9·1 answer
  • Write a method called min that takes three integers as parameters and returns the smallest of the three values, such that a call
    13·1 answer
  • Consider a classful IPv4 address 200.200.200.200? What is its implied subnet mask? If we take the same address and append the CI
    12·1 answer
  • What is the difference between the flip horizontal and the flip vertical option
    8·1 answer
  • What are the inputs that the model uses to make decisions?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!