How do you get a method from recursing infinitely? In the example below, It asks for a double value, then another. The first value must be less than the second value. If not, it will ask you to enter a double that is less than the second one. After that, it will allow you to enter 2 more doubles but the problem is it keeps going and won't stop. So what do I need to put in there to make it stop afterwards?
Example:
public static void getOperands() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter a double value");
double operand1 = scnr.nextDouble();
System.out.println("Enter another double value");
double operand2 = scnr.nextDouble();
if(operand1 < operand2) {
calcPercentage(operand1, operand2);
}
else
System.out.println("Enter a double that is less than the second double");
getOperands();
}