Discover the answers to your questions at Westonci.ca, where experts share their knowledge and insights with you. Our Q&A platform offers a seamless experience for finding reliable answers from experts in various disciplines. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
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--; }
Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.