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]
4 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]4 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
How to transfer crypto from coinbase to coinbase wallet
posledela

Answer:

Open Coinbase Wallet on your mobile device.

Tap to go to your Settings.

Tap Buy or Transfer.

Select the supported crypto.

Enter the amount you want to transfer then tap Continue.

Follow the remaining steps to complete your transfer.

7 0
2 years ago
Write a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated to
svp [43]

Answer:

public static String repeat(String text, int repeatCount) {

   if(repeatCount < 0) {

       throw new IllegalArgumentException("repeat count should be either 0 or a positive value");

   }

   if(repeatCount == 0) {

       return "";

   } else {

       return text + repeat(text, repeatCount-1);

   }

}

Explanation:

Here repeatCount is an int value.

at first we will check if repeatCount is non negative number and if it is code will throw exception.

If the value is 0 then we will return ""

If the value is >0 then recursive function is called again untill the repeatCount value is 0.

6 0
3 years ago
All members within a class are by default
miv72 [106K]

Answer:

All the members within a class are by default are private. Private function in a class can access public function within a similar class. Private member formed the implementation of the class and also form the private interface of members within the class.

All the member of class can be access by function inside the class when it is declare as private.

For example:

class test

{     private:

   int a; // when test:a is private

     public:

   test() : a()  // a is accessible in test class  

}

8 0
3 years ago
____ data exist in a format that does not lend itself to processing that yields information.
Nastasia [14]
The word that goes in the blank is "unstructured."
4 0
4 years ago
Instrument Air system that employ a standby header shall be permitted to have a simplex cooler and dryer. Where a standby header
Vinil7 [7]

The standby header is provide a check valve shall be installed to prevent backflow.

<h3>What is instrument air?</h3>

The phrase “Instrument Air” is a term that connote  a thoroughly clean supply of compressed air that is said to be very free from any kind of contaminations such as particles.

Note that a system often utilize instrument air for different kinds of pneumatic tools, also that of valves and electrical controls.

See full question below

Instrument Air system that employ a standby header shall be permitted to have a simplex cooler and dryer. Where a standby header is provided, a ___________ shall be installed to prevent backflow.

answer choices

one way valve

two way check valve

check valve

Isolation valve

Learn more about Instrument from

brainly.com/question/26219918

7 0
2 years ago
Other questions:
  • You created a database related to medicinal plants and their uses. For every plant, you would like to enter a description about
    11·1 answer
  • To provide both encryption and integrity protection, wpa2 uses aes encryption with:
    12·1 answer
  • Which function returns a valid value without any arguments?
    13·2 answers
  • Fill in the blank <br>computers are closed in......​
    6·1 answer
  • Sensitive data is always classified true or false
    14·1 answer
  • Visual basis,C, C++ and Java are all examples of computer programming ________.
    15·1 answer
  • An administrator wants to configure hosts to automatically assign IPv6 addresses to themselves by the use of Router Advertisemen
    14·1 answer
  • What are ya'll discords???
    10·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    12·2 answers
  • Why is a Quality assurance tester needed on a software development team?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!