Write a while loop that verifies that the user enters a positive integer value.

What will be an ideal response?


```
Scanner scan = new Scanner(System.in);
System.out.print("Enter a positive integer: ");
number = scan.nextInt();
while (number <= 0)
{
System.out.print("That number was not positive.");
System.out.print("Enter a positive integer: ");
number = scan.nextInt();
}
```

Computer Science & Information Technology

You might also like to view...

The number of times that a method calls itself is known as the ___________________ of recursion.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Which of the following is NOT a type of memory?

A) Cache B) CPU registers C) RAM D) ALU

Computer Science & Information Technology

Answer the following statement(s) true (T) or false (F)

1. One of the most common tasks in science and engineering is finding the roots of equations. 2. Many of the theorems you learned for roots of polynomials don’t apply to transcendental equations. 3. The regula falsi procedure can be made to converge more rapidly if the interval can be made to collapse from only one direction. 4. With the regula falsi method of root-finding, success is based on the size of the function, not the size of the interval. 5. The secant method of root-finding does not pose divergence problems.

Computer Science & Information Technology

Disk fragmentation causes reduced disk performance because the disk read/write heads must move longer distances.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology