Hello, all. Attached is a simple (for most) program that I'm working on.

Here is the code I've produced so far:

package quadrant;

import java.util.Scanner;

public class Quadrant 
{
    public static int x1;
    public static int y1;
    public static int x2;
    public static int y2;

    public static int Coordinate1Quadrant(int x1, int y1)
    {
        int coordinate1quadrant = 0;

        if (x1 > 0 && y1 > 0)
        {
            coordinate1quadrant = 1;
        }

        else if (x1 < 0 && y1 > 0)
        {
            coordinate1quadrant = 2;
        }

        else if (x1 > 0 && y1 > 0)
        {
            coordinate1quadrant = 3;
        }    

        else if (x1 > 0 && y1 < 0)
        {
            coordinate1quadrant = 4;
        }

        return coordinate1quadrant;
    }

    public int Coordinate2Quadrant(int x2, int y2)
    {
        int coordinate2quadrant = 0;

        if (x2 > 0 && y2 > 0)
        {
            coordinate2quadrant = 1;
        }

        else if (x2 < 0 && y2 > 0)
        {
            coordinate2quadrant = 2;
        }

        else if (x2 > 0 && y2 > 0)
        {
            coordinate2quadrant = 3;
        }    

        else if (x2 > 0 && y2 < 0)
        {
            coordinate2quadrant = 4;
        }

        return coordinate2quadrant;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        Scanner input = new Scanner(System.in);
        System.out.print("Please enter a value for x1: ");
        x1 = input.nextInt();
        System.out.print("Please enter a value for y1: ");
        y1 = input.nextInt();
        System.out.print("Please enter a value for x2: ");
        x2 = input.nextInt();
        System.out.print("Please enter a value for y2: ");
        y2 = input.nextInt();

        if (Coordinate1Quadrant == Coordinate2Quadrant)
        {
            System.out.print("These coordinates are in the same quadrant.");
        }

        else if ( (Coordinate1Quadrant == 1 && Coordinate2Quadrant == 2)
                ||(Coordinate1Quadrant == 1 && Coordinate2Quadrant == 4)
                ||(Coordinate1Quadrant == 2 && Coordinate2Quadrant == 3)
                ||(Coordinate1Quadrant == 2 && Coordinate2Quadrant == 1)
                ||(Coordinate1Quadrant == 3 && Coordinate2Quadrant == 2)
                ||(Coordinate1Quadrant == 3 && Coordinate2Quadrant == 4)
                ||(Coordinate1Quadrant == 4 && Coordinate2Quadrant == 1)
                ||(Coordinate1Quadrant == 4 && Coordinate2Quadrant == 3))
        {
            System.out.print("These coordinates are in adjacent quadrants.");
        }
        else if ( (Coordinate1Quadrant == 1 && Coordinate2Quadrant == 3)
                ||(Coordinate1Quadrant == 2 && Coordinate2Quadrant == 4)
                ||(Coordinate1Quadrant == 3 && Coordinate2Quadrant == 1)
                ||(Coordinate1Quadrant == 4 && Coordinate2Quadrant == 2))
        {
            System.out.print("These coordinates are in opposite quadrants.");
        }    

    }
}

I'm getting a lot of errors with this, and I'm pretty sure it stems with the methods I set up (Coordinate1Quadrant and Coordinate2Quadrant). I'm not profecient with them whatsoever. If someone could please show me the right direction I'd grealy appreciate it.

Member Avatar for gowans07

what sort of errors?

Member Avatar for gowans07

you need to declare the variables Coordinate1Quadrant and Coordinate2Quadrant in the main method.

can you tell me the exact error?

check your spelling of Coordinate1Quadrant and Coordinate2Quadrant
and you haven't given parameters to the method Coordinate1Quadrant and Coordinate2Quadrant.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.