Write a short code fragment that uses a while loop to verify that the user enters a positive integer as input. You may assume that a Scanner object named input has already been created.
What will be an ideal response?
```
System.out.print("Please enter a positive value: ");
int value = input.nextInt();
while(value <= 0) {
System.out.println("Error (the number was not positive)");
System.out.print("Please enter a positive value: ");
value = input.nextInt();
}
```
You might also like to view...
What is whitespace and why is it import when reading input from the keyboard using the Scanner class?
What will be an ideal response?
Task analysis may involve: (select all that apply)
- learning task-specific software - conducting ethnographic studies - speaking to application users about their experiences - quietly and unobtrusively watching as a user interacts with an application
When you have multiple graphics positioned on a page, you can ____ them so that they are a single graphic instead of separate graphics.
A. link B. group C. cluster D. index
The result_vector of a LOOKUP function must be sorted in ascending order.
a. true b. false