Looking for answers? Westonci.ca is your go-to Q&A platform, offering quick, trustworthy responses from a community of experts. Get detailed and accurate answers to your questions from a community of experts on our comprehensive Q&A platform. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform.
Sagot :
Answer:
The program in Java is as follows:
import java.util.*;
import java.lang.Math;
public class Rooter{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int start;
System.out.print("Start: ");
start = input.nextInt();
while(start<=0){
System.out.print("Number must be positive\nStart: ");
start = input.nextInt(); }
while(start>=0){
System.out.println(Math.sqrt(start));
start--; }
}
}
Explanation:
This declares start as integer
int start;
This prompts the user for input
System.out.print("Start: ");
This gets input for start
start = input.nextInt();
The following is repeated until the user input is valid i.e. positive
while(start<=0){
System.out.print("Number must be positive\nStart: ");
start = input.nextInt(); }
The following while loop prints the square root of each number till 0
while(start>=0){
System.out.println(Math.sqrt(start));
start--; }
Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.