SHARE
TWEET

Untitled

a guest Feb 27th, 2020 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main {
  2.  
  3.     /**
  4.      * @param args the command line arguments
  5.      */
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int[] array = new int[10];
  9.         for(int i = 0; i < array.length; i++) {
  10.             System.out.println("Number " + (i + 1) + ":");
  11.             array[i] = scanner.nextInt();
  12.            
  13.         }
  14.         System.out.println("Min: " + findMin(array));
  15.         System.out.println("Max: " + findMax(array));
  16.         System.out.println("Average: " + calculateAverage(array));
  17.        
  18.        
  19.     }
  20.     public static int findMin(int[] array) {
  21.         int min = array[0];
  22.        
  23.         for (int i = 0; i < 10; i++) {
  24.             if (array [i] < min) {
  25.                 min = array[i];
  26.                
  27.             }
  28.         }
  29.         return min;
  30.     }
  31.     public static int findMax(int[] array) {
  32.         int max = array[0];
  33.        
  34.         for (int i = 0; i < 10; i++) {
  35.             if (array [i] > max) {
  36.                 max = array[i];
  37.                
  38.             }
  39.         }
  40.         return max;
  41.        
  42.     }
  43.     public static double calculateAverage(int[] array) {
  44.         int sum = 0;
  45.         for (int i = 0; i < array.length; i++) {
  46.             sum += array[i];
  47.            
  48.         }
  49.         return (double)sum / array.length;
  50.        
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top