I have to create a program in which I input 2 values simultaneously but, these values must range from 50 to 127. If the value is less than 50 or above 127 it should show an exception saying "value entered" is too low or too high. As a requirement for the program, I cannot use flow-control statements. I have not tried anything as I am lost UPDATE: WITH THE HELP OF YOUR COMMENTS I HAVE SATISFIED THE 127 CONDITION, AND MAY BE ON THE WAY TO SATISFYING THE LOWER CONDITION WITH THE NEXT(PATTERN) METHOD. I AM CURRENTLY CONTACTING MY TEACHER AND ASKING IF SATISFYING THE 127 CONDITION IS ENOUGH. THANK YOU ALL
UPDATE 2: the 127 condition was enough!
import java.util.Scanner;
public class A1_Q1 {
public static void main(String[] args) {
// declaration of variables
double x, y, z;
int p, q;
Scanner kBoard = new Scanner(System.in);
System.out.println("Welcome to the Simple 3D-Space Program:");
System.out.println("+++++++++++++++++++++++++++++++++++++++");
System.out.print("Enter values for 'p' and 'q' simultaneously. Must be between 50 and 127:");
String input = kBoard.nextLine();
//separating first number and second number from the inputed line
String firstNum = input.substring(0, input.indexOf(" "));
String secondNum = input.substring(input.indexOf(" "), input.length());
//isolating numbers from the strings and filtering out
String numOnlyP = firstNum.replaceAll("[^0-9]", "");
String numOnlyQ = secondNum.replaceAll("[^0-9]", "");
//transforming string into integer values
p = Integer.parseInt(numOnlyP);
q = Integer.parseInt(numOnlyQ);
//to check and see if previous code was functioning correctly
System.out.println(p + " " + q);
}
}