I want to make a loop that repeat requesting for input until the user finally satisfies the condition of a number input instead of a string. By the way I'm using BufferedReader here. Is there a way to repeat it in BigInteger and BufferedReader?
mainLoop: while(true) {
System.out.println("Choose a number:");
System.out.println("1 - Addition");
System.out.println("2 - Subtraction");
System.out.println("3 - Multiplication");
System.out.println("4 - Division");
System.out.println("5 - QUIT");
try {
int choice = Integer.parseInt(myObj.readLine());
BigInteger Num1, Num2, sum, diff, qoutient, product;
String num1 = null, num2 = null;
switch (choice) {
case 1:
try {
num1 = myObj.readLine();
Num1 = new BigInteger(num1);
num2 = myObj.readLine();
Num2 = new BigInteger(num2);
sum = Num1.add(Num2);
System.out.println("The answer is "+sum);
} catch (NumberFormatException e){
}break;
The output actually returns to the main loop.