Ano po ang mali?saan ako nagkamali?
Java:
import java.util.Scanner;
public class Circle implements Shape {
private double radius;
private double xc;
private double yc;
public Circle(double radius, double xc, double yc) {
this.radius = radius;
this.xc = xc;
this.yc = yc;
}
public double area() {
return Math.PI * radius * radius;
}
public boolean contains(double x, double y) {
double distance = Math.sqrt((x - xc) * (x - xc) + (y - yc) * (y - yc));
return distance <= radius;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the radius of the circle: ");
double radius = scanner.nextDouble();
System.out.print("Enter the x coordinate of the center of the circle: ");
double xc = scanner.nextDouble();
System.out.print("Enter the y coordinate of the center of the circle: ");
double yc = scanner.nextDouble();
Circle circle = new Circle(radius, xc, yc);
System.out.println("Area of the circle: " + circle.area());
System.out.print("Enter a point to check if it is within the circle (enter x and y coordinates separated by a space): ");
double x = scanner.nextDouble();
double y = scanner.nextDouble();
if (circle.contains(x, y)) {
System.out.println("The point (" + x + ", " + y + ") is within the circle.");
} else {
System.out.println("The point (" + x + ", " + y + ") is not within the circle.");
}
}
}