Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/JPA02.java
Last active May 24, 2017

Embed
What would you like to do?
TQC+ JAVA
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() {
System.out.print("請輸入x座標: ");
double x = keyboard.nextDouble();
System.out.print("請輸入y座標: ");
double y = keyboard.nextDouble();
if(x == 0 && y == 0) {
System.out.println("(" + x + "," + y + ") 在原點上");
}
if(x == 0 && (y > 0 || y < 0)) {
System.out.println("(" + x + "," + y + ") 在y軸上");
}
if(y == 0 && (x > 0 || x > 0)) {
System.out.println("(" + x + "," + y + ") 在x軸上");
}
if(x > 0 && y > 0) {
System.out.println("(" + x + "," + y + ") 在第一象限");
}
if(x < 0 && y > 0) {
System.out.println("(" + x + "," + y + ") 在第二象限");
}
if(x < 0 && y < 0) {
System.out.println("(" + x + "," + y + ") 在第三象限");
}
if(x > 0 && y < 0) {
System.out.println("(" + x + "," + y + ") 在第四象限");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.