返回列表 發帖
  1. package test;

  2. import java.util.Scanner;

  3. public class JPA02 {
  4. static Scanner keyboard = new Scanner(System.in);
  5.         public static void main(String[] args) {
  6.                
  7.                 // TODO 自動產生的方法 Stub
  8.                 test();        
  9.         test();
  10.         test();
  11.         test();
  12.         }
  13.          static void test() {
  14.                  System.out.print("請輸入x座標 : ");
  15.                  int x=keyboard.nextInt();
  16.                  System.out.print("請輸入y座標 : ");
  17.                  int y=keyboard.nextInt();
  18.                  
  19.          if(x>0)
  20.          {
  21.                  if(y>0)
  22.                  {
  23.                          System.out.println("座標值+在第一象限");
  24.                  }
  25.                  else if(y<0)
  26.                  {
  27.                          System.out.println("座標值+在第四象限");
  28.                  }
  29.                  else
  30.                  {
  31.                          System.out.println("座標值+在x軸上");
  32.                  }
  33.          }
  34.          else if(x<0)
  35.          {
  36.                  if(y>0)
  37.                  {
  38.                          System.out.println("座標值+在第二象限");
  39.                  }
  40.                  else if(y<0)
  41.                  {
  42.                          System.out.println("座標值+在第三象限");
  43.                  }
  44.                  else
  45.                  {
  46.                          System.out.println("座標值+在y軸上");
  47.                  }
  48.                  
  49.          }
  50.          else{
  51.                    if(y==0)
  52.                    {
  53.                            System.out.println("座標值+在原點上");  
  54.                    }
  55.                    else{
  56.                          System.out.println("座標值+在y軸上");
  57.                    }
  58.                  }
  59.             }
  60.          }
複製代碼

TOP

返回列表