In: Computer Science
Using C# Design and implement a program (name it CheckPoint) that prompts the user to enter the x-coordinate then y-coordinate of a point (in a Cartesian plane) as integer values. The program prints out the entered values followed by the location of the point on the plane. The possibilities for a point are: the origin point, on the x-axis, on the y-axis, in the first quadrant, in the second quadrant, in the third quadrant, or in the fourth quadrant. Format the outputs following the sample runs below.
Sample run 1:
X-coordinate is 0
Y-coordinate is 0
(0, 0) is the origin point.
using System;
class CheckPoint
{
// Function to check quadrant
static void quadrant(int x, int y)
{
if (x > 0
&& y > 0)
Console.WriteLine("("+x+","+y+")"+"
lies in First quadrant");
else if (x < 0
&& y > 0)
Console.WriteLine("("+x+","+y+")"+"
lies in Second quadrant");
else if (x < 0
&& y < 0)
Console.WriteLine("("+x+","+y+")"+"
lies in Third quadrant");
else if (x > 0
&& y < 0)
Console.WriteLine("("+x+","+y+")"+"
lies in Fourth quadrant");
else if (x == 0
&& y > 0)
Console.WriteLine("("+x+","+y+")"+"
is on the positive y axis");
else if (x == 0
&& y < 0)
Console.WriteLine("("+x+","+y+")"+"
is on the negative y axis");
else if (y == 0
&& x < 0)
Console.WriteLine("("+x+","+y+")"+"
is on the negative x axis");
else if (y == 0
&& x > 0)
Console.WriteLine("("+x+","+y+")"+"
is on the positive x axis");
else
Console.WriteLine("("+x+","+y+")"+"
is the origin point");
}
static void Main(string[] args)
{
Console.Write("Enter
X-Coordinate: ");
string X =
Console.ReadLine();
Console.Write("Enter
Y-Coordinate: ");
string Y =
Console.ReadLine();
int x =
Convert.ToInt32(X);
int y =
Convert.ToInt32(Y);
Console.WriteLine("X-coordinate
is "+x);
Console.WriteLine("Y-coordinate
is "+y);
quadrant(x,y);
Console.Read();
}
}
/* PLEASE UPVOTE */