import java.util.*;
public class CartesianCoordinates
{
static Scanner console = new Scanner(System.in);
public static void main (String[] args)
{
int x;
int y;
System.out.println();
while (true) {
System.out.printf("\nEnter x and y coordinates of a" + "\npoint in a Cartesian Plane: ");
System.out.printf("\nTo stop the program, Enter #");
x = console.nextInt();
y = console.nextInt();
System.out.printf("The Coordinates you entered are " + x + " and " + y);
if (x == 0 && y == 0)
System.out.printf("\nThe Point is the Origin.");
if (x != 0 && y == 0)
System.out.printf("\nThe point is located" + "\n on the x-axis.");
if (x == 0 && y != 0)
System.out.printf("\nThe point is located" + "\n on the y-axis.");
if (x > 0 && y > 0)
System.out.printf("\nThe point is located" + "\n on the First Quadrant.");
if (x < 0 && y > 0)
System.out.printf("\nThe point is located" + "\n on the Second Quadrant.");
if (x < 0 && y < 0)
System.out.printf("\nThe point is located" + "\n on the Third Quadrant.");
if (x > 0 && y < 0)
System.out.printf("\nThe point is located" + "\n on the Fourth Quadrant.");
if(x == #) {
System.out.printf("\nInvalid Input.\n"
+ "Terminate Coordinates program.");
break;
}
}
}
}
Edited by ZekeDragon, 17 May 2010 - 02:35 AM.
Use [code] tags (the # button) when posting code.


Sign In
Create Account


Back to top









