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
Write a new method in the Rectangle class to test if a Point falls within the rectangle. For this exercise, assume that a rectan
algol [13]

Answer:

Explanation:

The Rectangle and Point class is not provided in this question but was found online. Using that code as guidance I created the following method named contains. This method takes in a Point object and checks to see if the x-axis point is inside the parameters of the Rectangle class and then checks the same for the y-axis. If it is inside the Rectangle then the method returns true otherwise it returns false.

def contains(self, point):

       return self.width > point.x >= self.corner.x and self.height > point.y >= self.corner.y

7 0
3 years ago
When water reaches the pole, most of it turns to ice. Some salt is trapped between ice crystals, but most is left behind in the
astra-53 [7]

Answer:

b should be the right answer

Explanation:

8 0
3 years ago
Read 2 more answers
What role does modern technology play in globalization today?
lana [24]

<span>Advances in technology are one of the main reasons that globalization has escalated in the past decade. In information and communication technology, innovations have become smaller in size, more efficient and often more affordable. In transport technology, vehicles have tended to become larger and faster, as well as becoming more environmentally friendly and cheaper to run. Whether for personal use or for business, technology has made the world seem a smaller place and assisted in the rise of globalization. </span>
6 0
3 years ago
What should an administrator use to more easily assign database access permissions to multiple users?
Kruka [31]

Answer:

to allow administrators to assign rights and permissions to multiple users

Explanation:

8 0
3 years ago
What is the last step to a URL search
Molodets [167]
U paste it the u press enter

4 0
3 years ago
Other questions:
  • Assume that a program consists of integer and floating-point instructions. 60% of the total execution time is spent on floating
    7·1 answer
  • Which person would be the best fit for a career in the information technology field?
    14·1 answer
  • Discuss how advertising on the Web affects search results and the ethical dilemmas associated with it.
    5·1 answer
  • Which of the following is involved in creating technical communication?
    7·1 answer
  • Each webpage is assigned a(n) ______, an address that identifies the location of the page on the Internet.
    6·1 answer
  • What does the regular expression [a-z0-9\-] mean?
    8·1 answer
  • What is entered into a cell that is typically numeric and can be used for calculations?
    9·2 answers
  • Does this look anywhere close to the APA Format?
    6·1 answer
  • 21
    5·1 answer
  • (PLATO) Which of these games was a graphical adventure game?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!