Answer to Question #274484 in Java | JSP | JSF for kkkkkk

Question #274484

The quadrant in which line drawn from the origin resides



is determined by the angle that the line makes with the



positive x axis as follows:



Using this information, write a Java method that accepts the



angle of the line as user input and determines and displays



the quadrant appropriate to the input data. (Note: if the



angle is exactly 0, 90, 180, or 270 degrees the corresponding



line does not reside in any quadrant but lies on an axis).



Note: Use if Control statement

1
Expert's answer
2021-12-02T06:47:06-0500
import java.io.*;
import java.util.Scanner;
 class Main{
    static void qua(int angle, int angle2)
    {
        if (angle >0 && angle2 > 0)
            System.out.println("lies in First quadrant");
 
        else if (angle < 0 && angle2 > 0)
            System.out.println("lies in Second quadrant");
 
        else if (angle < 0 && angle2 < 0)
            System.out.println("lies in Third quadrant");
 
        else if (angle > 0 && angle2 < 0)
            System.out.println("lies in Fourth quadrant");
 
        else if (angle == 0 && angle2 > 0)
            System.out.println("lies at positive y axis");
 
        else if (angle == 0 && angle2 < 0)
            System.out.println("lies at negative y axis");
 
        else if (angle2 == 0 && angle < 0)
            System.out.println("lies at negative x axis");
 
        else if (angle2 == 0 && angle > 0)
            System.out.println("lies at positive x axis");
 
        else
            System.out.println("lies at origin");
    }
    public static void main(String[] args)
    {
        Scanner input=new Scanner(System.in);
        int angle = input.nextInt();
        int angle2 = input.nextInt();
        qua(angle, angle2);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS