- 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 35 times
The following code segment has been created. the code can be placed in a method. The code keeps asking the user to enter
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
The following code segment has been created. the code can be placed in a method. The code keeps asking the user to enter
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;