Finding the largest number and smallest number given the user input (METHODS)
<p>I'm stuck on trying to enter the correct code to find the largest number and the smallest number from the user input Here's my code so far, I was able to find the average, is there an operator I can use? :</p>

<pre><code>package labs;

import java.util.Scanner;

public class Lab7method {

public static double readNumber(Scanner input, String prompt, String errorMessage, boolean toBePositive, boolean askForInteger) {
boolean hasError = true;    // assume to have error
double number = 0;  //initialize number


while (hasError) {
        // Prompt the user to input
        System.out.print(prompt);

        // Check if it is non-numeric data
        if (!input.hasNextDouble()) {   
            // If it is, report the error
            System.out.println(errorMessage);
            input.next();   // throw the input away by reading it
        } else if (askForInteger &amp;&amp; !input.hasNextInt()) {
            // report the non-integer error
            System.out.println(errorMessage);
            input.next();   // throw the input away by reading it
        }
        else {
            // read the number
            number = input.nextDouble();

            // if the caller wants only positive number, check for negative or zero
            if (toBePositive &amp;&amp; number &lt;= 0)
                System.out.println(errorMessage); // report the error
            else
                // end the error checking loop
                hasError = false;
        }
    }

    // return the number to the caller
    return number;
}

// the really used method
public static int readInteger(Scanner input, String prompt, String errorMessage) {
    // invoke the readNumber() to an integer
    int anInteger = (int)readNumber(input, prompt, errorMessage, false, true);

    // return to the caller
    return anInteger;
}


// the really used method
public static double readDouble(Scanner input, String prompt, String errorMessage) {
    // invoke the readNumber() to do the actual work
    double aNumber = readNumber(input, prompt, errorMessage, false, false);

    // return to the caller
    return aNumber;
}

// the really used read positive double method
public static double readPositiveDouble(Scanner input, String prompt, String errorMessage) {
    // invoke the readNumber() to get a positive floating point number
    double aNumber = readNumber(input, prompt, errorMessage, true, false);

    // return to the caller
    return aNumber;
}

public static int readPositiveInt(Scanner input, String prompt, String errorMessage) {
    int anposInteger = (int) readNumber(input, prompt, errorMessage, true, false);
    return anposInteger;
}

public static void main(String[] args) {
    // Create a Scanner object
    Scanner input = new Scanner(System.in);

    //initial account balance//

    int noofgrades = readPositiveInt(input, "Enter number of grades: ", "Error you did not enter a positive integer:");
    double lowestGrade = 0;
    double highestGrade = 0;    
    double sumOfGrade = 0;
    double grade = 0;



    for (int i = 0; i &lt; noofgrades; i++){           

        double Grade = 0;   
    // monthly interest rate//

    double mograde = readPositiveDouble(input, "Please enter grade " + (i +1) + ": ", "Errorrrrrrrr");


    sumOfGrade += mograde;
    }

    double averagegrade = sumOfGrade/noofgrades;

     // Do I use these -&gt; Double.MAX_VALUE;
     // Do I use these -&gt; Double.MIN_VALUE;     


        System.out.printf("The average of the grades entered are: %4.2f\n"
                            + "The highest grade: %4.2f\n" + "The lowest grade is: %4.2f\n" 
                            , averagegrade, highestGrade, lowestGrade);                                                         
</code></pre>