0

why my code cant calaulate the square numbers

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("enter the number: "); double number =input.nextDouble(); double guess,answer; for (answer = 1;answer < number;answer+=0.1) { guess = answer*answer; if (guess == number ) { System .out .println (answer) ; break ; } else if (guess > number ) { System .out.println (answer) ; break ; } } } }

4th Sep 2016, 11:58 PM
Amir Hosein Bagheri
Amir Hosein Bagheri - avatar
2 Answers
0
Can you explicitly explain what your intention is, i've read over your source code and i can see that some of the code is prone to errors. However we can minimize this or completly make it work without any errors but you have to explain what your intention is ?
5th Sep 2016, 12:30 AM
Ousmane Diaw
0
i wanna calculate the second root
5th Sep 2016, 8:40 PM
Amir Hosein Bagheri
Amir Hosein Bagheri - avatar