Use java method to find minimum among entered five numbers
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class App {
/**
* The start point of the program
*
* @param args
*/
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
List<Integer> intValues = new ArrayList<>();
for (int i = 0; i < 5; i++) {
System.out.print("Enter number " + (i + 1) + ": ");
intValues.add(keyBoard.nextInt());
}
Integer min = Collections.min(intValues);
System.out.println("Minimum number: " + min);
keyBoard.close();
}
}
Comments
Leave a comment