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]
3 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]3 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 calculate 3 X (50 + 40) ÷ 5 on excel 2016
kozerog [31]

Answer:

I think this might help, don't know much of this

Explanation:

How do you calculate 3.5 increase in Excel?

How To Increase a Number By a Percentage. If want to calculate a percentage increase in Excel (i.e. increase a number by a specified percentage), this can be done by simply multiply the number by 1 + the percentage increase. - which gives the result 60.

8 0
3 years ago
Read 2 more answers
What name is used to denote a common field that exists between two tables, but is also the primary key for one of the tables??"
Diano4ka-milaya [45]

Answer:

b. foreign key

Explanation:

In the database world, a foreign key is a field on one table and a primary key for another table. The purpose of a foreign key is to provide linkages between two or more tables. Given two tables A and B, and making A the point of reference, a primary key is a field that is unique in A while a foreign key is unique in B.

On another hand, a composite primary key is a combination of two or more fields/columns on database table that can be used to uniquely identify each row in the table.

In the database lingua, what we have is a unique key not a distinct key, though the two words are similar in meaning.

A duplicate key is used when an information may be repeatedly entered on a table.

So the correct option is a foreign key.

4 0
3 years ago
Design a program that will receive a valid time in the 24-hour format (e.g. 2305) and convert to its equivalent 12-hour format (
coldgirl [10]

Answer:

import java.io.*;

public class Main

{

  public static void main(String[] args) throws IOException {

      BufferedReader bufferObject=new BufferedReader(new InputStreamReader(System.in));

      String stringObject=bufferObject.readLine();

      while(!stringObject.equals("99:99AM")){

      System.out.println(convertedTime(stringObject));

      stringObject=bufferObject.readLine();

      }

  }

  public static String convertedTime(String stringObject){

  String s=stringObject.substring(stringObject.length()-2);

  String[] timeObject=stringObject.substring(0,5).split(":");

  if(s.equals("AM")){

  if(timeObject[0].equals("12")) return "00"+timeObject[1];

  else return timeObject[0]+timeObject[1];

  }

  else{

  if(timeObject[0].equals("12")) return "12"+timeObject[1];

  else{

  int hours=Integer.valueOf(timeObject[0]);

  timeObject[0]=String.valueOf(12+hours);

  return timeObject[0]+timeObject[1];

  }

  }

 

  }

}

Explanation:

  • Inside the main method run a while loop until stringObject is not equal to the string "99:99AM".
  • Call the convertedTime method and display the results.
  • Use the same hours and minutes except for 12th hour If the time is in AM.
  • Use "00" instead of 12, if it is 12th hour.
  • Add hours to 12, if the time is in PM and don't change anything in case of 12.
8 0
3 years ago
Today you turned on your computer after being on vacation for a week. You see spinning white dots on a black screen. You decide
Andre45 [30]

Answer:

<em>Use Safe Mode to boot</em>

Explanation:

Safe mode uses a <em>limited number of files and drivers to begin Windows in a simple form. If an issue does not arise in safe mode, this means that the problem is not caused by default settings and simple system drivers.</em>

Windows in safe mode helps users to track down the cause of a problem and therefore can enable users to solve problems on the computer.

The steps include:

  1. Reboot your computer.
  2. Click the F8 button before the logo appears on Windows 7 and above.
  3. Using the arrow keys to navigate and select which operating system you would like to boot into Safe Mode if you have more than one operating system installed on the same computer.
  4. Use the arrow keys to select Safe Mode and press Enter.

4 0
2 years ago
Look at the following list of peripheral items and determine what type they are: mouse, keyboard, webcam, microphone. Input Outp
-Dominant- [34]

Keyboard and mouse are input/output

Webcam and microphone are audio/visual


6 0
3 years ago
Other questions:
  • Kendall receives an email stating that a leading computer company is giving away free computers, asking her to forward the email
    15·1 answer
  • Every character is represented by a code. The ASCII code for upper letter A is 65 and for lower a is 97. Similarly the numeric c
    9·1 answer
  • Even closed systems are never perfectly closed. <br>true false​
    10·1 answer
  • When did the mantle of the earth form
    14·2 answers
  • ____ is a method of querying and reporting that takes data from standard relational databases, calculates and summarizes the dat
    11·1 answer
  • Simplify the expresion<br>12. 12g + 9g​
    13·1 answer
  • A string variable can hold digits such as account numbers and zip codes.<br><br> FALSE<br><br> TRUE
    14·1 answer
  • WAFL (write-anywhere file layout) Select one: a. is a distributed file system b. is a file system dedicated to single user opera
    6·1 answer
  • Write a program that gets three input characters which are user's initials and displays them in a welcoming message. Then gets i
    12·1 answer
  • Refund please, this has not helped at all.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!