Advertisement
sylviapsh

Cartesian Coordinate System

Dec 27th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2. class CartesianCoordinateSystem
  3. {
  4.   static void Main()
  5.   {
  6.     //Telerik Academy
  7.     //You are given a two-dimensional Cartesian coordinate system and the two coordinates (X and Y) of a point in the coordinate system. As you will find, the coordinate system is divided by 2 lines (see the picture bellow) which divide the plain in four parts. Each of these parts has a lot of points that are numbered between 1 and 4. There is one point where our lines are crossing. This point has the following coordinates: X=0 and Y=0. As a result this point is numbered 0. The points on the lines are also numbered with the numbers 5 and 6 (again see the picture below).
  8. //Your task is to write a program that finds the number of the location of the given point in the coordinate system.
  9.  
  10.     double coordinateX = double.Parse(Console.ReadLine()),
  11.            coordinateY = double.Parse(Console.ReadLine());
  12.  
  13.     if (coordinateX == 0 && coordinateY == 0)
  14.     {
  15.       Console.WriteLine("0");
  16.     }
  17.     else if (coordinateX > 0 && coordinateY > 0)
  18.     {
  19.       Console.WriteLine("1");
  20.     }
  21.     else if (coordinateX < 0 && coordinateY > 0)
  22.     {
  23.       Console.WriteLine("2");
  24.     }
  25.     else if (coordinateX < 0 && coordinateY < 0)
  26.     {
  27.       Console.WriteLine("3");
  28.     }
  29.     else if (coordinateX > 0 && coordinateY < 0)
  30.     {
  31.       Console.WriteLine("4");
  32.     }
  33.     else if (coordinateX == 0 && coordinateY != 0)
  34.     {
  35.       Console.WriteLine("5");
  36.     }
  37.     else if (coordinateX !=0 && coordinateY == 0)
  38.     {
  39.       Console.WriteLine("6");
  40.     }
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement