63 066
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #27214 in Java | JSP | JSF for MARK KEVIN

Question #27214
7. Write a program that accepts the value of (x, y) x-coordinates and y-coordinates and output its equivalent quadrant, if x = 0, its lies on the x axis, , if y = 0, its lies on the y axis, and if (0,0) origin.
Expert's answer
import java.util.Scanner;public class Test {
publicstatic void main(String[] args) {
Scanners = new Scanner(System.in);

System.out.println("enterx:");
intx = s.nextInt();
System.out.println("entery:");
inty = s.nextInt();

System.out.println(checkQuadrant(x,y));
}

publicstatic String checkQuadrant(int x, int y) {
Stringres;

if(x == 0 || y == 0) {
if(x == 0 && y == 0) {
res= "Origin";
}else {
res= (x == 0) ? "its lies on the x axis"
:"its lies on the y axis";
}
}else {
if(x > 0) {
res= (y > 0) ? "its lies on 1st quadrant"
:"its lies on 4st quadrant";
}else {
res= (y > 0) ? "its lies on 2st quadrant"
:"its lies on 3st quadrant";
}
}
returnres;
}
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions