/home/caleb/ASDV-Java/Assignments/lab16_arrays2_CalebFontenot/src/main/java/com/calebfontenot/lab16_arrays2_calebfontenot/ArraysAndMethodsGames.java

    /*
     * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
     * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
     */
    package com.calebfontenot.lab16_arrays2_calebfontenot;

    import java.util.Scanner;

    /**
     *
     * @author caleb
     */
    public class ArraysAndMethodsGames {
     public static double min(double[] array) {
         // pull the first number from the array, and compare that with the numbers in the rest of the array. If that number is less than the number in than the first number, set it to our lowest.
         double lowest = array[0];
         for (int i = 1; i < (array.length -1); i++) {
             lowest = Math.min(lowest, array[i]);
         }
         return lowest;
     }

        public static double[] readArray() {
            // Create a double array.
            int doublesRemaining = 10;
            double[] returnArray = new double[doublesRemaining];
            // Create Scanner
            Scanner input = new Scanner(System.in);
            // Read characters input and write them to an array.
            int i = 0;
            do {
            System.out.print("Enter 10 doubles (" + doublesRemaining + " left ): ");
            returnArray[i] = input.nextDouble();
            i++;
            doublesRemaining--;
            } while (doublesRemaining != 0);
            return returnArray;
        }

        /**
         *
         * @param array
         * @return Returns an average of an array.
         */
        public static double average(double[] array) {
            // Iterate through array and add values together into double, then divide by the amount of items in the array.
            double returnDouble = 0.0;
            for (double i: array) {
                returnDouble += i;
            }
            returnDouble /= (double) array.length;
            return returnDouble;
        }

        public static void main(String[] args)
        {
            double[] doubleArray = new double[10];
            doubleArray = readArray();
            System.out.println("average function returns: " + average(doubleArray));
            System.out.println("lowest function returns: " + min(doubleArray));
        }
    }