Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete Java program called Rooter that gets a positive integer called

ID: 3828837 • Letter: W

Question

Write a complete Java program called Rooter that gets a positive integer called "start" from the user at the command line and then finds the squareroot of every number from "start" down to 0. Use a while loop to count down. Print each square root on a separate line. Include data validation to ensure the user provides a positive integer. Assume that the user enters an integer, and for validation, just check to be sure it is positive. 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.

Explanation / Answer

//I am only writing the logic//

Scanner reader = new Scanner(System.in); // Reading from System.in

System.out.println("Enter a number: ");

int val = reader.nextInt();

while (val>=0 )

{

val= Math.sqrt(double val);

val--;

}

while (val<=0)

{

printf("Invalid Response please enter positive entry");

val = userInput.nextInt();

}

}

//used while loop for both conditions

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote