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 Live Tiles feature in Windows 8 give users a constant stream of information, but the user can also switch the option off
Indicate whether the statement is true or false
A(n) ________ control is a control that contains descriptive information, typically a field name
A) label B) bound C) unbound D) calculated