Skip to content

Instantly share code, notes, and snippets.

@peter279k
Last active May 24, 2017 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/e3bbbef303bbf1024ad011005d38abf2 to your computer and use it in GitHub Desktop.
Save peter279k/e3bbbef303bbf1024ad011005d38abf2 to your computer and use it in GitHub Desktop.
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