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
A red wavy line under a word means _____. a change has been made in the text a new word was inserted in the document there is a
zloy xaker [14]
Hi there!

The correct option is C. <span>there is a spelling mistake. The red wavy line indicates that a word was spelled incorrectly, sometimes though this function does not recognize the word it can mark it as incorrect even when it is not, in which case you can right-click the marked word and add it to your computer's internal word dictionary. Right-clicking an incorrectly spelled word will also give a short list of words that are similar to the one you are trying to spell, clicking on one of the given words will automatically change the marked word to the one you chose.

-Your friend, ASIAX</span>
7 0
3 years ago
Read 2 more answers
Ld' is the instruction with the longest latency on the CPU from Section 4.4 (in RISC-V text). If we modified ld and sd so that t
antiseptic1488 [7]

Answer:

See explaination

Explanation:

a)

The primary factors that influence the program's speed on a new CPU are given as:-

CPU Clock speed where the speed of the process instructions is being measured.

Multi-core which is when the transistors work faster than respective CPU.

Cache which helps to note that the transition of data is smooth and fast.

b)

So, there are two CPUs suppose the old one as 'A' and the modified one as 'B'.

'A' has following features---

It takes more time to execute program as it has more clock cycle time or we can say it has low clocking rate or low speed in terms of MHz or GHz. Clock rate is the inverse of Clock Cycle Time. When you will increase the clocking rate of CPU, it will get faster and then Clock Cycle Time will get reduced.

It has less instructions provided.

'B' has following features----

It takes less time to execute program as it has less clock cycle time or we can say it has high clocking rate or high speed in terms of MHz or GHz.

It has more instructions provided.

The performance of CPU depends upon 2 factors:

The number and types of instructions that are executed by the CPU

How fast the CPU can execute those instructions?

So, overall CPU B is better as it has less execution time than CPU A but the performance will always depend upon the number and type of instructions executed by the CPU so it may vary.

Please refer to attachment for instructions and formulas.

8 0
3 years ago
Design a circuit that has a 3-bit binary input B2, B1, B0 (where B2 is most significant bit and B0 is least significant bit) and
jenyasd209 [6]

Isn't this circuit just a wire, where Z=B0?

3 0
3 years ago
Why ues storage unit?​
Jet001 [13]

Huh? I don’t understand your question... please be more specific so we can help you

6 0
3 years ago
Lisa and her husband would like to buy a house soon. She continuously pays bills late. How do her actions affect her and others?
stiks02 [169]
Well actually it affects her credit. Home owners would not want to sell a house to someone who doesn't pay bills on time. It shows he/she is unreliable

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which protocol do many browsers assume when you enter a URL in the address field?
    9·1 answer
  • Henrietta, the owner of a very successful hotel chain in the Southeast, is exploring the possibility of expanding the chain into
    15·1 answer
  • An ideal line length would include how many characters? A. 6570 B. 100 C. 100125 D. 4055
    8·1 answer
  • Where could an identity theft access your personal information?
    9·2 answers
  • Which describes the hypothesis of an experiment? the variable changed by the experimenter/ the quantity that must remain constan
    9·1 answer
  • Select the correct answer.
    10·1 answer
  • Brainliest
    13·2 answers
  • which of the following protocols allows hosts to exchange messages to indicate problems with packet delivery?
    14·1 answer
  • What is the minimum ethernet frame size that will not be discarded by the receiver as a runt frame?.
    8·1 answer
  • Which of the following is the system of rules and structure governing
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!