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
kodGreya [7K]
4 years ago
12

What is one potential problem with the following loop? System.out.print("Enter integers. Enter -1 to exit."); System.out.println

(" Count of integers entered will be returned."); int n=0; int c=0; while (n != -1) { n = scan.nextInt(); c++; } System.out.println(c);
Computers and Technology
1 answer:
iris [78.8K]4 years ago
7 0

Answer:

The answer to this question can be given as  

The potential problem with the loop is it's counts when the user enters -1 from the keyboard, so the count will too many.

Explanation:

In the program there some line is missing. So the right program of the  question can be given as:  

import java.util.*;     //import package for take input from user.

public class Main     //define main class.

{

public static void main(String[] args)//define main function

{

Scanner scan=new Scanner(System.in);          //creating object.

//print values.

System.out.print("Enter integers. Enter -1 to exit.");

System.out.println(" Count of integers entered will be returned.");  

 int n=0,c=0;           //declaring integer variable.

  while (n != -1)             //loop

   {

       n = scan.nextInt();               //take input by user and hold on variable n.  

       c++;

   }

 System.out.println(c);               //print value.

}

}

output:

Enter integers. Enter -1 to exit. Count of integers entered will be returned.

-1

1  

You might be interested in
. What is suboptimization?
Vera_Pavlovna [14]

Answer: Suboptimization is referred to as a term that has been approved for common policy mistake. It usually refers to the practice of concentrating on a single component of a whole and thus making changes which are intended towards improving that component and also ignoring its effects on other components.

3 0
3 years ago
Please help me what is an example of a growing trend on social media
Marizza181 [45]

Answer:

B

Explanation:

8 0
3 years ago
What is the name of the item that supplies the exact or near exact voltage at the required wattage to all of the circuitry insid
Karo-lina-s [1.5K]

Answer:

<em>A voltage regulator.</em>

<em></em>

Explanation:

<em>A voltage regulator, controls the output of an alternating current or a direct current (depending on the design), allowing the exact amount of voltage or wattage to be supplied to the computer hardware</em>. This device sometimes uses a simple feed-forward design or may include negative feedback. The two major types of voltage regulator are based on either the electromechanical or electronic components.

<em>The electronic types were based on the arrangement of resistor in series with a diode or series of diodes, and the electromechanical types are based on coiling the sensing wire to make an electromagnet. </em>

4 0
4 years ago
Using a while loop, create an algorithm extractDigits that prints the individual digits of a positive integer.
sergiy2304 [10]

Answer:

The algorithm is as follows

1. Start

2. Declare Integer N

3. Input N

4. While N > 0:

4.1    Print(N%10)

4.2   N = N/10

5. Stop

Explanation:

This line starts the algorithm

1. Start

This declares an integer variable

2. Declare Integer N

Here, the program gets user input N

3. Input N

The while iteration begins here and it is repeated as long as N is greater than 0

4. While N > 0:

This calculates and prints N modulus 10; Modulus of 10 gets the individual digit of the input number

4.1    Print(N%10)

This remove the printed digit

4.2   N = N/10

The algorithm ends here

5. Stop

<u>Bonus:</u>

The algorithm in Python is as follows:

<em>n = 102</em>

<em>while n>0:</em>

<em>     print(int(n%10))</em>

<em>     n= int(n/10)</em>

<em>    </em>

8 0
3 years ago
Kyla, a business analyst uses test scripts while testing an application before it is released to the client. Why do business ana
Mariana [72]

Answer:

D. to create a test environment

Explanation:

After releasing it will be "production"

8 0
3 years ago
Other questions:
  • What is an online alternative to customers sending checks via mail?
    7·1 answer
  • It is important to keep a copy of your written plan and safety records off-site. A) True B) False
    6·2 answers
  • It is essential that a security professional is able to resolve and respond to cyber law inquiries and incidents while avoiding
    14·1 answer
  • Does anyone know the code for codeHS 5.4.7 teenagers?
    8·1 answer
  • What is an electronic path over which data can travel.
    7·1 answer
  • What do you do to add a line or circle to your presentation?
    7·2 answers
  • Python
    14·1 answer
  • a term to describe article that can be displayed in their entirety as opposed to abstract and reference only?​
    10·1 answer
  • 12. What separated Grand turismo from other racing games was its focus on ______.
    13·1 answer
  • A person is sledding down a hill at a speed of 9 m/s. The hill gets steeper and his speed increases to 18 m/s in 3 sec. What was
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!