第3章:幾何方面:點是否在圓內?

/**
 * 幾何方面:點是否在圓內?
 * 提示用戶輸入一個點 (x, y):
 * 檢查這個點是否在以原點 (0, 0)爲圓心、半徑爲10的園內。
 */
package Test;

import java.util.Scanner;

public class T322Scanner {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter a point weith two coordinates: ");
		double x = input.nextInt();
		double y = input.nextInt();
		
		double m = Math.pow((x * x + y * y), 0.5);
		System.out.println((m > 10 ? "Point (" + x + ", " + y + ") is not in the circle!"
				                   : "Point (" + x + ", " + y + ") is in the circle!"));
	}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章