返回列表 發帖

209-象限座標

import java.util.*;
public class JPD02 {
    static Scanner keyboard = new Scanner(System.in);
    public static void main(String[] args) {
        test();        
        test();
        test();
        test();
    }
   
    public static void test() {

    }
}
Stay hungry,
Stay foolish.

  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. 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

  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

package jihgh;

import java.util.Scanner;

public class dbxdbff {
        static Scanner k = new Scanner(System.in);
   
        
        public static void main(String[] args) {
                // TODO 自動產生的方法 Stub

                test();        
        test();
        test();
        test();
       
        }
        private static void test() {
                System.out.print("請輸入艾克斯和歪");
                double x=k.nextDouble();
                double y=k.nextDouble();
       
               


                if(x>0)
                {
                        if(y<0)
                        {
                                System.out.printf("<%.2f,%.2f>在第四象限",x,y);
                        }
                        else if(y>0)
                        {
                                System.out.printf("<%.2f,%.2f>在第一象限",x,y);
                        }
                        else if(y==0)
                        {
                                System.out.printf("<%.2f,%.2f>在x軸",x,y);
                        }
                }
                        if(x<0)
                        {
                                if(y<0)
                                {
                                        System.out.printf("<%.2f,%.2f>在第三象限",x,y);
                                }
                                else if(y>0)
                                {
                                        System.out.printf("<%.2f,%.2f>在第二象限",x,y);
                                }
                                else if(y==0)
                                {
                                        System.out.printf("<%.2f,%.2f>在x軸",x,y);
                               
                               
                                }
                        }
                               
                        else if(x==0)       
                {                               
                if(y>0 ||y<0)
        {
                System.out.printf("<%.2f,%.2f>在y軸",x,y);
        }
                else if(y==0)
        {
                System.out.printf("<%.2f,%.2f>在原點",x,y);
        }       
                }
                }}

TOP

1
2
3
4
5
6
7
8
9
10

TOP

返回列表