Assistance with assignment question

Write a program that prompts the user for a value greater than 10 as an input (you should loop
until the user enters a valid value) and finds the square root of that number and the square root of
the result, and continues to find the square root of the result until we reach a number that is
smaller than 1.01. The program should output how many times the square root operation was
performed.

Below is all i managed to get so far.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 

import java.util.Scanner;

  public class SkrtProgram
	{
     public static void main(String[] args)
     {


    	Scanner scan = new Scanner(System.in);
    	System.out.println("Lets find the sq root of a value greater than 10");
    	String garbage ="";

			while(true)
			{
				System.out.println("Enter a number a number greater than 10 ");

				if(scan.hasNextDouble()){
					double skrt = scan.nextDouble();

					if (skrt > 10){
						//input is good;
						System.out.println("output is " + skrt);
						break;
					}
				}
				garbage = scan.nextLine(); //throw out the line
			}//end first while loop




	}
}
And your question is what ?
Im only able to find the square of number greater than 10 i need another while loop for square root of the results and I can't figure out how to

" continues to find the square root of the result until we reach a number that is
smaller than 1.01. The program should output how many times the square root operation was
performed".
This is a C++ forum, kdotod78 - your code is in java and it doesn't appear to find the square root of anything.

You appear to be in the wrong place doing the wrong thing.
Last edited on
alright any chance of you directing me in the right place.
Topic archived. No new replies allowed.