Page 1 of 1

The following code segment has been created. the code can be placed in a method. The code keeps asking the user to enter

Posted: Fri May 20, 2022 5:49 pm
by answerhappygod
The Following Code Segment Has Been Created The Code Can Be Placed In A Method The Code Keeps Asking The User To Enter 1
The Following Code Segment Has Been Created The Code Can Be Placed In A Method The Code Keeps Asking The User To Enter 1 (446.3 KiB) Viewed 37 times
The following code segment has been created. the code can be placed in a method. The code keeps asking the user to enter a double value until the user provides a valid input. Once a valid input is entered the loop ends and the method returns the value However it has an infinite loop. Fill in the blank so that the method works. int done = 0; double input = 0; while (done!= -1) { try { System.out.print("Enter an double: "); input = kb.nextDouble(); } catch(Exception e) { System.out.println("You did not enter a valid input "); } kb.nextLine(); } return input;