返回列表 發帖
  1. import java.util.Scanner;


  2. public class JPA01 {
  3.            static Scanner keyboard = new Scanner(System.in);
  4.             public static void main(String[] args) {
  5.                 test();        
  6.                 test();
  7.                 test();
  8.                 test();
  9.             }
  10.             
  11.             public static void test() {
  12.                     System.out.print("請輸入x座標:");
  13.                     float x=keyboard.nextFloat();
  14.                     System.out.print("請輸入y座標:");
  15.                     float y=keyboard.nextFloat();
  16.                     if(x>0)
  17.                     {
  18.                             if(y>0)
  19.                             {
  20.                                     System.out.printf("(%.2f,%.2f)在第一象限\n",x,y);
  21.                             }
  22.                             else if(y<0)
  23.                             {
  24.                                     System.out.printf("(%.2f,%.2f)在第四象限\n",x,y);
  25.                             }
  26.                             else
  27.                             {
  28.                                     System.out.printf("(%.2f,%.2f)在x軸上\n",x,y);
  29.                             }
  30.                     }
  31.                     else if(x<0)
  32.                     {
  33.                             if(y>0)
  34.                             {
  35.                                     System.out.printf("(%.2f,%.2f)在第二象限\n",x,y);
  36.                             }
  37.                             else if(y<0)
  38.                             {
  39.                                     System.out.printf("(%.2f,%.2f)在第三象限\n",x,y);
  40.                             }
  41.                            
  42.                     }
  43.                     else
  44.                     {
  45.                             if(y==0)
  46.                             {
  47.                                     System.out.printf("(%.2f,%.2f)在原點上\n",x,y);
  48.                             }
  49.                             else
  50.                             {
  51.                                     System.out.printf("(%.2f,%.2f)在y軸上\n",x,y);
  52.                             }
  53.                     }
  54.             }
  55.         }
複製代碼

TOP

  1. import java.util.Scanner;


  2. public class JPA01 {
  3.            static Scanner keyboard = new Scanner(System.in);
  4.             public static void main(String[] args) {
  5.                 test();        
  6.                 test();
  7.                 test();
  8.                 test();
  9.             }
  10.             
  11.             public static void test() {
  12.                     System.out.print("請輸入x座標:");
  13.                     float x=keyboard.nextFloat();
  14.                     System.out.print("請輸入y座標:");
  15.                     float y=keyboard.nextFloat();
  16.                     if(x>0)
  17.                     {
  18.                             if(y>0)
  19.                             {
  20.                                     System.out.printf("(%.2f,%.2f)在第一象限\n",x,y);
  21.                             }
  22.                             else if(y<0)
  23.                             {
  24.                                     System.out.printf("(%.2f,%.2f)在第四象限\n",x,y);
  25.                             }
  26.                             else
  27.                             {
  28.                                     System.out.printf("(%.2f,%.2f)在x軸上\n",x,y);
  29.                             }
  30.                     }
  31.                     else if(x<0)
  32.                     {
  33.                             if(y>0)
  34.                             {
  35.                                     System.out.printf("(%.2f,%.2f)在第二象限\n",x,y);
  36.                             }
  37.                             else if(y<0)
  38.                             {
  39.                                     System.out.printf("(%.2f,%.2f)在第三象限\n",x,y);
  40.                             }
  41.                             else
  42.                             {
  43.                                     System.out.printf("(%.2f,%.2f)在x軸上\n",x,y);
  44.                             }
  45.                     }
  46.                     else
  47.                     {
  48.                             if(y==0)
  49.                             {
  50.                                     System.out.printf("(%.2f,%.2f)在原點上\n",x,y);
  51.                             }
  52.                             else
  53.                             {
  54.                                     System.out.printf("(%.2f,%.2f)在y軸上\n",x,y);
  55.                             }
  56.                     }
  57.             }
  58.         }
複製代碼

TOP

1
2
3
4
5
6
7
8
9
10

TOP

返回列表