Question: Write a java code to get a positive integer ( any number greater than 0 ) called stop from the user at the command line

Write a java code to get a positive integer ( any number greater than 0) called "stop" from the user at the command line using a Scanner object; and then find the square root of every number from 1 up through and including stop number. Use a while loop to count up. As an example, if the user entered 8, you would find the square root of 1, then the square root of 2, and so on up to the square root of 8. Requirements: First, include data validation to ensure the user provides a positive integer. If the validation is not passed, provide the user with suitable feedback and stay in the program to let the user try again until valid input is received. Use the Math.sqrt(double a) method to find each square root and output the integer and the result using three decimal positions. Print each square root on a separate line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!