Write a complete Java program that prompts the user for a series of numbers to determine the smallest value entered. Before the program terminates, display the smallest value.
What will be an ideal response?
```
import java.util.Scanner;
public class FindMin
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int smallest = 9999999;
String userInput;
boolean quit = false;
System.out.println("This program finds the smallest number"
+ " in a series of numbers");
System.out.println("When you want to exit, type Q");
while(quit != true)
{
System.out.print("Enter a number: ");
userInput = keyboard.next();
if(userInput.equals("Q") || userInput.equals("q"))
{
quit = true;
}
else
{
int userNumber = Integer.parseInt(userInput);
if(userNumber < smallest)
smallest = userNumber;
}
}
System.out.println("The smallest number is " + smallest);
System.exit(0);
}
}
```
You might also like to view...
The try block cannot:
a. Enclose the code that may throw the exception. b. Enclose its own catch blocks. c. Test enclosing try blocks for additional catch statements if this try block’s catch statements can’t match the exception being thrown. d. Have exceptions explicitly or implicitly thrown in the try block itself.
To insert rows, click the cell where you want to insert a row, then click _____________ from the Rows & Columns group on the TABLE TOOLS LAYOUT contextual tab.
A. Insert Row B. Insert Above C. Insert Below D. either Insert Above or Insert Below
When the user clicks any of the three standard JFrame buttons, a ___________ is generated.
(a) window listener (b) window event (c) window activator (d) window deactivator
Each heading formatted with the Heading 2 style in Word becomes a ____.
A. first-level bulleted item B. second-level bulleted item C. first-level title D. sub-title