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 ; } } } }
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 ?
0
i wanna calculate the second root