4
Contributors
6
Replies
61
Views
3 Years
Discussion Span
Last Post by mk12345
0

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.");
        }    

    }
}
0

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.

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.