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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post 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 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 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;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply