Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(JAVA) write a program IN JAVA that uses a method called quadrant that accepts a

ID: 3768409 • Letter: #

Question

(JAVA) write a program IN JAVA that uses a method called quadrant that accepts as parameters a pair of double values representing an (x, y) point and returns the quadrant number for that point. Recall that quadrants are numbered as integers from 1 to 4 with the upper-right quadrant numbered 1 and the subsequent quadrants numbered in a counterclockwise fashion: xid-111609318_1 Notice that the quadrant is determined by whether the x and y coordinates are positive or negative numbers. Return 0 if the point lies on origin (point 0,0). return a -1 if the point is on the x axis, return -2 if the point is on the y axis. For example, the call of quadrant(-2.3, 3.5) should return 2 and the call of quadrant(4.5, -4.5) should return 4. The values for x and y should be entered by the user, and the where the point is located should be output by another method Name the class project3............................ based offf

Explanation / Answer

public class Quadrant{
   public static int quadrant(double x,double y){
       if(x > 0 && y > 0)
           return 1;
       else if( x < 0 && y > 0)
           return 2;
       else if( x < 0 && y < 0)
           return 3;
       else if( x > 0 && y < 0)
           return 4;
       else
           return 0;
   }
   public static void main(String args[]){
       Scanner in = new Scanner(System.in);
       int x = in.nextDouble();
       int y = in.nextDouble();
       System.out.println("Quadrant number :" + quadrant(x,y));

   }
}