Write a Program to Find the Minimum and Maximum Sum Using Array Concept In java Language
Answers
Answered by
0
public class Numbers
{
public static void main(String[] args)
{
System.out.println("Enter Some Numbers");
Scanner demo = new Scanner(System.in);
Integer[] hello = new Integer[5];
for (int i=0;i<hello.length;i++)
{
System.out.print("Enter numbers["+i+"]:");
hello[i]=demo.nextInt();
}
int min = (int) Collections.min(Arrays.asList(hello));
int max = (int) Collections.max(Arrays.asList(hello));
System.out.println("Min number: " + min);
System.out.println("Max number: " + max);
}
}
Hope this helps!
{
public static void main(String[] args)
{
System.out.println("Enter Some Numbers");
Scanner demo = new Scanner(System.in);
Integer[] hello = new Integer[5];
for (int i=0;i<hello.length;i++)
{
System.out.print("Enter numbers["+i+"]:");
hello[i]=demo.nextInt();
}
int min = (int) Collections.min(Arrays.asList(hello));
int max = (int) Collections.max(Arrays.asList(hello));
System.out.println("Min number: " + min);
System.out.println("Max number: " + max);
}
}
Hope this helps!
Similar questions