Question

Design a Java application that prompts the user to

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class Ex1_1{

public static void main(String []args){
Scanner sc=new Scanner(System.in);   
System.out.println("Enter the coordinates in cartesian plane"); //asking for the input from the user
int x=sc.nextInt(); //storing the x-axis value in x
int y=sc.nextInt(); //storing the y-axis value in x
if((x==0 && y!=0)||(y==0 && x!=0)) // condition for determing whether the point is in either x-axis or y-axis
{
if(x==0)
System.out.println("("+x+","+y+")"+" is on the y-axis");
else
System.out.println("("+x+","+y+")"+" is on the x-axis");


}
else if(x==0&&y==0)
System.out.println("("+x+","+y+")"+" is the origin");               // condition for determing whether the point is the origin   

else
{
if(x>0 && y>0)
System.out.println("("+x+","+y+")"+" is in the first quadrant ");   // condition for determing whether the point is in the first quadrant
else if(x<0 && y>0)
System.out.println("("+x+","+y+")"+" is in the second quadrant ");   // condition for determing whether the point is in the second quadrant
else if(x<0 && y<0)
System.out.println("("+x+","+y+")"+" is in the third quadrant "); // condition for determing whether the point is in the third quadrant
else
System.out.println("("+x+","+y+")"+" is in the fourth quadrant "); // condition for determing whether the point is in the fourth quadrant
  
}


}
}


/********************output begins *********************/
Enter the coordinates in cartesian plane
0   
0   
(0,0) is the origin
Enter the coordinates in cartesian plane
4   
0   
(4,0) is on the x-axis
Enter the coordinates in cartesian plane
0   
-3
(0,-3) is on the y-axis
Enter the coordinates in cartesian plane
-2
3   
(-2,3) is in the second quadrant

/********************output ends *********************/
Please let me know in case you have any doubts.

Add a comment
Know the answer?
Add Answer to:
Design a Java application that prompts the user to input the x- and y-coordinates of a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to input the x-y coordinate of a point in...

    Write a program that prompts the user to input the x-y coordinate of a point in a Cartesian plane. The program should then output a message indicating whether the point is the origin, is located on the x ( or y ) axis, or appears in a particular quadrant. using only iostream and functions

  • Using C# Exercise #3: Design and implement a program (name it CheckPoint) that prompts the user...

    Using C# Exercise #3: Design and implement a program (name it CheckPoint) that prompts the user to enter the x-coordinate then y-coordinate of a point (in a Cartesian plane) as integer values. The program prints out the entered values followed by the location of the point on the plane. The possibilities for a point are: the origin point, on the x-axis, on the y-axis, in the first quadrant, in the second quadrant, in the third quadrant, or in the fourth...

  • PLEASE DO IN PSEUDOCODE; Design and implement a program (name it CheckPoint) that prompts the user...

    PLEASE DO IN PSEUDOCODE; Design and implement a program (name it CheckPoint) that prompts the user to enter the x-coordinate then y-coordinate of a point (in a Cartesian plane) as integer values. The program prints out the entered values followed by the location of the point on the plane. The possibilities for a point are: the origin point, on the x-axis, on the y-axis, in the first quadrant, in the second quadrant, in the third quadrant, or in the fourth...

  • Write a program that takes the x, y coordinates of a point in the Cartesian plane...

    Write a program that takes the x, y coordinates of a point in the Cartesian plane and prints a message telling either which axis the point lies on or the quadrant in which it is found. Sample Output (-1.0, -2.5) is in quadrant 3 (0.0, -4.8) is on the y-axis IN C CODE PLEASE! (NOT C++)

  • (use the JOptionPane methods for input and output) Write a java application that prompts the user...

    (use the JOptionPane methods for input and output) Write a java application that prompts the user to input an integers x. Then the program should call the method isAutomorphic to check if the integer x is automorphic*or not. At the end the program should output a message to indicate if x is automorphic or not *In Mathematics, an automorphic number is a number that ends with the same digit that its square ends with. For Example: 762 = 5776    è  (76 is...

  • Design a Java program that asks the user to enter an integer number n and then...

    Design a Java program that asks the user to enter an integer number n and then generates an array of that many random points (x, y) with x- and y-coordinates in the range between 0 and 100. After this the program must ask the user to enter two diagonal points (x_1, y_1) and (x_2, y_2) of a rectangle with sides parallel to the coordinate axis (see the image below, where possible pairs of diagonal points are shown in red color)....

  • Write a Java application that prompts the user for pairs of inputs of a product number...

    Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (this is two separate prompts for input values). You must use a switch statement and a sentinel-controlled loop (i.e. a loop that stops execution when an out of range value, such as -1, is input). All 15 items below are for a single purchase. There are five sets of inputs as follows: Product 1    1...

  • Its java class pratice  problem (Geometry: point in a rectangle?) Write a program that prompts the user...

    Its java class pratice  problem (Geometry: point in a rectangle?) Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5.  For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to10 / 2 and...

  • Write a Java console application that prompts the user to enter the radius of a circle,...

    Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...

  • Write a java application to input 2 positive integers X and Y such that X is...

    Write a java application to input 2 positive integers X and Y such that X is less than Y. Then the program should do the following: 1. Output the sum of even integers between 1 and X. 2. Output the average of odd integers between 1 and Y. 3. Output the common divisors of X and Y.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT