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();
}
```
Computer Science & Information Technology
You might also like to view...
Web applications are designed around a __________ model, meaning the one computer produces data while another uses data.
a. Client-Server b. Peer-to-Peer c. Master-Slave d. Server-User
Computer Science & Information Technology
According to the ITGI, what are the four supervisory tasks a board of directors should perform to ensure strategic InfoSec objectives are being met?
What will be an ideal response?
Computer Science & Information Technology