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
How many lines are on a standard sheet of typing paper?
kotegsom [21]
60 lines on the paper
3 0
3 years ago
Company ABC has always used passwords to protect the highly confidential information in their company. Recently, someone who was
Leno4ka [110]
Company ABC should use passwords but also have them use a code so that not just anyone can get in. Kinda like facebook.
3 0
3 years ago
Which results are expected in a personality test but not a skills assessment?
dimaraw [331]

Answer:

openness, conscientiousness, extraversion

Explanation:

A personality test is defined as a test that is used to assess the human personality. It is designed as the techniques to measure characteristics patterns of the traits that various people shows at different situations or environments.

A skill assessment test is used to test the abilities and the skill sets of people to perform a particular tasks given to them. It is measuring the knowledge and skills of a person.

The personality test are carried out to test how human behave and what traits they show in certain conditions. Thus openness, extra version and conscientiousness are some of the traits that people usually shows in a personality test. Thus they are the results that are expected by an individual of a personality test.

6 0
2 years ago
Write a function called is_present that takes in two parameters: an integer and a list of integers (NOTE that the first paramete
Agata [3.3K]

Answer:

The function in python is as follows

def is_present(num,list):

    stat = False

    if num in list:

         stat = True

       

    return bool(stat)

Explanation:

This defines the function

def is_present(num,list):

This initializes a boolean variable to false

    stat = False

If the integer number is present in the list

    if num in list:

This boolean variable is updated to true

         stat = True

This returns true or false        

    return bool(stat)

7 0
3 years ago
You created a two-dimensional array with the following code.
Dennis_Churaev [7]

Explanation:

I would say aList[1][2]

6 0
3 years ago
Read 2 more answers
Other questions:
  • Sam's manager would like him to create and distribute copies of a budget report for each department. The budget report should sh
    8·2 answers
  • Grid computing is a type of computing in which:
    15·1 answer
  • According to the lecture, when communicating men prefer to concentrate on _____________.
    13·1 answer
  • From the television industry's point of view, which of the following would be the most desirable viewer?
    5·1 answer
  • What task does the casting director do, apart from auditioning actors?
    8·1 answer
  • What does ctto mean?
    11·2 answers
  • Write a recursive function that prints out the items of a (possibly empty) singly linked list of integers in reverse order. The
    5·1 answer
  • For what purpose is IT used in business?
    7·1 answer
  • Is the app scener safe? its a chrome webstore app on computer.​
    13·1 answer
  • An electronics company develops a line of augmented reality headsets for use in interactive 3d media applications using 5g mmwav
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!