In: Computer Science
How many numbers do you wish to enter? 5
Please enter a number: 8
Please enter a number: 9
Please enter a number: 12
Please enter a number: 15
Please enter a number: 3
The minimum number is 3 and the maximum number is 15.
CODE IN JAVA:
import java.util. * ;
public class main {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
int min = 999999, max =
-99999;
System.out.print("How many numbers
do you wish to enter? ");
int n = sc.nextInt();
for(int i = 1; i <= n; i++)
{
System.out.print("Please Enter a number: ");
int number =
sc.nextInt();
if(number >
max)
max = number ;
if(number <
min)
min = number ;
}
System.out.println("The minimum
number is " + min + " and the maximum number is " + max +
".");
}
}
OUTPUT: