TQC+ JAVA 209 象限座標
import java.util.*;
public class JPA02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
test();
test();
}
public static void test() {
float x,y;
System.out.printf("請輸入x座標:");
x=keyboard.nextFloat();
System.out.printf("請輸入y座標:");
y=keyboard.nextFloat();
if(x==0 && y==0)
System.out.printf("(%.2f,%.2f)在原點上%n",x,y);
if(x>0 && y==0)
System.out.printf("(%.2f,%.2f)在x軸上%n",x,y);
if(x==0 && y>0)
System.out.printf("(%.2f,%.2f)在y軸上%n",x,y);
if(x>0 && y>0)
System.out.printf("(%.2f,%.2f)在第一象限%n",x,y);
if(x<0 && y>0)
System.out.printf("(%.2f,%.2f)在第二象限%n",x,y);
if(x<0 && y<0)
System.out.printf("(%.2f,%.2f)在第三象限%n",x,y);
if(x>0 && y<0)
System.out.printf("(%.2f,%.2f)在第四象限%n",x,y);
}
}
沒有留言:
張貼留言