using C++ please solve the following Write a program that takes the x - y coordi
ID: 654223 • Letter: U
Question
using C++ please solve the following
Write a program that takes the x - y coordinates of a point in the Cartesian plane and prints a message telling that the point is either The origin (0, 0) On the x axis On the y axis The quadrant in which it is found. The program should continually ask the user to enter the x and y coordinates until they enter a 'q' for quit. Sample lines of output: (-1,0, -2.5) is in quadrant III (0.0,4.0) is on the y-axis (3.2,0) is on the x-axis (5.7, 8.3) is in quadrant I (7.1, -8.8) is in quadrant IV (-5.9,2.3) is in quadrant II (0,0) is the origin Run your program with the above data and print the output as above.Explanation / Answer
program done in java
import java.util.Scanner;
public class CartesainPlane
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double x,y;
Sysyem.out.print(" please enter the x-coordinate of the point:);
x = sc.nextInt();
Sysyem.out.print(" please enter the y-coordinate of the point:);
x = sc.nextInt();
if((x==0) && (y==0))
{
System.out.println("the point of the origin");
}
else if(x==0)
{
System.out.println("the point lie on the y-axis");
}
else if(y==0)
{
System.out.println("the point on the x-axis");
}
else if(x<0)
{
if(y>0)
{
System.out.println("the point lies in the second quadrant");
}
else
{
System.out.println("the point in the third quadrant");
}
}
else
{
if(y>0)
{
System.out.println("the point in the first quadrant");
}
else
{
System.out.println("the point in the forth quadrant");
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.