At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Connect with professionals ready to provide precise answers to your questions on our comprehensive Q&A platform. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A 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--; }
We appreciate your time. Please come back anytime for the latest information and answers to your questions. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.