Computer Science, asked by basitashraf67315, 9 months ago

write a program in java​

Attachments:

Answers

Answered by bibiangelicaputot
0

public class FindLargestSmallestNumber {

public static void main(String[] args) {

 //numbers array

 int numbers[] = new int[]{55,32,45,98,82,11,9,39,50};

 //assign first element of an array to largest and smallest

 int smallest = numbers[0];

 int largetst = numbers[0];

 for (int i = 1; i & lt; numbers.length; i++) {

  if (numbers[i] & gt; largetst)

   largetst = numbers[i];

  else if (numbers[i] & lt; smallest)

   smallest = numbers[i];

 }

 System.out.println("Largest Number is : " + largetst);

 System.out.println("Smallest Number is : " + smallest);

}

}

Answered by tiger009
0

Java Program

Explanation:

import java.util.Arrays;

import java.util.Collections;

public class Main {

public static void main(String[] args)

{

// Initializing array of integers

Integer[] n = {25, 60, 45, 15, 10};

// using Collections.min() to find minimum element

int minimum = Collections.min(Arrays.asList(n));

// using Collections.max() to find maximum element

int maximum = Collections.max(Arrays.asList(n));

// printing minimum and maximum numbers

System.out.println("Minimum number of array is : " + minimum);

System.out.println("Maximum number of array is : " + maximum);

}

}

The following are the description of the program.

  • Firstly, import the required pre defined packages and declare the main method.
  • Finally, set the required integer data type array and check the maximum and the minimum value from the array and print them.

Learn More:

https://brainly.in/question/15336073

Similar questions