We would like to write a program that prompts the user to enter a point (x, y)
Check whether the point is within the circle centered at (0, 0) with radius 10.
For example, (4, 5) is inside the circle and (9, 9) is outside the circle.
Hint: A point is in the circle if its distance to (0, 0) is less than or equal to 10.
import java.util.Scanner; public class Main { public static void main(String[] strings) { Scanner input = new Scanner(System.in); System.out.print("Enter X and Y coordinate: "); double x = input.nextDouble(); double y = input.nextDouble(); //your code here }// www . ja v a 2 s . c o m }
import java.util.Scanner; public class Main { public static void main(String[] strings) { Scanner input = new Scanner(System.in); System.out.print("Enter X and Y coordinate: "); double x = input.nextDouble(); double y = input.nextDouble(); if (Math.pow(x * x + y * y, 0.5D) <= 10.0) { System.out.println("Point (" + x + ", " + y + ") is in the circle"); } else { System.out.println("Point (" + x + ", " + y + ") is not in the circle"); } } }