/*
* 試撰寫一程式,輸入x、y 座標值,判斷該點位於那一個象限或是在座標軸上。舉例來
說,若輸入的座標值為 (3.0,-2.5),輸出即為第四象限;若輸入的座標值為 (4.5,0.0),
則輸出即為x 軸。
*/
import java.util.Scanner;
public class P5_2_11 {
public static void main(String[] args) {
System.out.println("請輸入座標x");
Scanner sc=new Scanner(System.in);
double x=sc.nextDouble();
System.out.println("請輸入座標y");
Scanner sc1=new Scanner(System.in);
double y=sc1.nextDouble();
if(x>=0&&y>=0){
System.out.println("輸入座標x=="+x+"y=="+y+"位於第1象限");
}
if(x<0&&y>=0){
System.out.println("輸入座標x=="+x+"y=="+y+"位於第2象限");
}
if(x<0&&y<0){
System.out.println("輸入座標x=="+x+"y=="+y+"位於第3象限");
}
if(x>=0&&y<0){
System.out.println("輸入座標x=="+x+"y=="+y+"位於第4象限");
}
}

}

/*

請輸入座標x
10
請輸入座標y
-5
輸入座標x==10.0y==-5.0位於第4象限

*/

arrow
arrow
    文章標籤
    java
    全站熱搜

    goodlucky23 發表在 痞客邦 留言(0) 人氣()