Advertisement
felix_de_suza

Coordinate System

May 21st, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.util.Scanner;
  3.  
  4. public class Test {
  5.    
  6.     public static void main(String[] args) {
  7.    
  8.         Scanner input = new Scanner(System.in);
  9.         BigDecimal xCoordinate = input.nextBigDecimal();
  10.         BigDecimal yCoordinate = input.nextBigDecimal();
  11.         BigDecimal zero = new BigDecimal(0);
  12.        
  13.         if ((xCoordinate.compareTo(zero) == 1) &&
  14.                 (yCoordinate.compareTo(zero) == 1)) {
  15.             System.out.println(1);
  16.         }
  17.         else if ((xCoordinate.compareTo(zero) == -1) &&
  18.                 (yCoordinate.compareTo(zero)) == 1) {
  19.             System.out.println(2);
  20.         }
  21.         else if ((xCoordinate.compareTo(zero) == -1) &&
  22.                 yCoordinate.compareTo(zero) == -1) {
  23.             System.out.println(3);
  24.         }
  25.         else if ((xCoordinate.compareTo(zero) == 1) &&
  26.                 (yCoordinate.compareTo(zero)) == -1) {
  27.             System.out.println(4);
  28.         }
  29.         else if(xCoordinate.equals(0) && yCoordinate.equals(0)) {
  30.             System.out.println(0);
  31.         }
  32.         else if (xCoordinate.equals(0)) {
  33.             System.out.println(5);
  34.         }
  35.         else {
  36.             System.out.println(6);
  37.         }
  38.        
  39.     }
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement