/** * A program to find and print to the console the minimun value * of a sequence of non negative integers. * The user will enter a negative number to signal end of input. * A value used to terminate a loop is called a sentinel value. * * @author Anthony Larrain * */ import java.util.Scanner; class Min{ public static void main(String [] args ) { Scanner input = new Scanner(System.in); System.out.println("Enter an integer (-1 to quit)"); int value = input.nextInt(); int min = value; while(value >= 0){ if (value < min){ min = value; } System.out.println("Enter an integer (-1 to quit)"); value = input.nextInt(); } if(min >= 0){ System.out.println("The min is " + min); }else{ System.out.println("No values entered"); } } }