i dont know where to put my getValidString validation when i ask the user if he wants to judge another
public class JudgingApp
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
DecimalFormat df = new DecimalFormat("0.##");//format decimals to 2 decimal places
//These variables hold the max and min numbers.
double maxNumber = Double.MIN_VALUE; // Maximum number
double minNumber = Double.MAX_VALUE; // Minimum number
//allow user to execute the code multiple times
String choice = "y";
while(choice.equalsIgnoreCase("y"))
//while(getValidString())
{
//variables
double realTotalNumber,number,totalNumber = 0;
//for loop to ask user to enter scores
for(int n = 1; n < 9; n++)
{
//get input from user
number = getNumberWithinRange(sc,"Enter score #" + n + ": ", 1.00, 10.00);
//records max and min numbers
if (number > maxNumber)
{
maxNumber = number;
}//end if
if (number < minNumber)
{
minNumber = number;
}//end if
//adds and records numbers inputted from user
totalNumber += number;
}//end forloop
//total of user inputs not including the min and max numbers entered
realTotalNumber = totalNumber -(minNumber+maxNumber);
//prints out the following
System.out.println("\nThe minimum score is " + df.format(minNumber));
System.out.println("The maximum score is " + df.format(maxNumber));
System.out.println("The total score is " + df.format(realTotalNumber));
//prompts user to continue
System.out.print("\nJudge another? (y/n): ");
choice = sc.next();
System.out.println();
}//end while
}//end MainMethod()
//method to validate the scores to be the correct data type and to be within the correct range
public static double getNumberWithinRange(Scanner sc, String prompt, double min, double max)
{
double d = 0;
boolean isValid = false;
while(isValid == false)
{
d = getDouble(sc, prompt);
if(d< min)
System.out.println("Error! Number must be "+ min +"0"+" or greater.");
else if(d> max)
System.out.println("Error! Number must be "+ max +"0"+" or less.");
else
isValid = true;//exit the loop because the value is within the specified range
}// end while loop
//return the valid data back to the caling mthod
return d;
}//end getNumberWithinRange()
//the getDouble() method gets input from the user, and validates, then returns to method getNumberWithinRange()
public static double getDouble(Scanner sc, String prompt)
{
double d = 0;
boolean isValid = false;
while(isValid == false)
{
System.out.print(prompt);
if(sc.hasNextDouble())
{
d = sc.nextDouble
();
isValid = true;//get out of the loop
}//end if
else
{
System.out.println("Error! invalid value. Try again. ");
}//end else
//discard anything left on the line
sc.nextLine();
}//end while loop
//return the valid data back to the calling method..getNumberWithinRange()
return d;
}//end getDouble()
public static String getValidString(Scanner sc, String prompt)
{
String s = "";
boolean isValid = false;
while(isValid ==false)
{
s = getString(sc,prompt);
if(s.equalsIgnoreCase("y") || s.equalsIgnoreCase("n"))
{
isValid = true;
}//end if
else
{
System.out.println("Error! Please enter y or n");
}//end else
}//end while
return s;
}//end getValidString
public static String getString(Scanner sc, String prompt)
{
String s = "";
boolean isValid = false;
while (isValid == false);
{
System.out.print(prompt);
s = sc.nextLine();
if (s.equals(""))
System.out.println("Error! Entry Required.");
else
isValid = true;
}//end while
return s;
}//end getString
}//end class