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
  • 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++)

  • 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...

  • 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...

  • 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...

  • Can I get the answers in Java, please? Write an application that prompts a user for...

    Can I get the answers in Java, please? Write an application that prompts a user for the number of years the user has until retirement and the amount of money the user can save annually. If the user enters a 0 or a negative number for either value, reprompt the user until valid entries are made. Display the amount of money the user will have at retirement. The total amount of money the user will have can be calculated with...

  • In Java, write a program that prompts the user to input a sequence of characters and...

    In Java, write a program that prompts the user to input a sequence of characters and outputs the number of vowels. You will need to write a method to return a value called isAVowel which will return true if a given character is a vowel and returns false if the character is not a vowel. A second method, called isAConstant, should return true if a given character is a constant and return false if the character is not a constant....

  • Design JavaFX application with 7 labels and one textfield where user enters input inches. When user...

    Design JavaFX application with 7 labels and one textfield where user enters input inches. When user enters his choice and presses enter key to complete input, program outputs resulting yards, feet, and inches. Use class P5 that extends Application with start method in it, and class P5Pane that extends GridPane. The only instance variables for P5Pane class are inputInches where user enters input inches, and three labels: outYards, outFeet, and outInches where program displays result of conversion. Use the following...

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
ADVERTISEMENT