Answer to Question #278182 in Java | JSP | JSF for Gauri

Question #278182

A point on the two-dimensional plane can be represented by two numbers: a X coordinate and a Y coordinate.

1
Expert's answer
2021-12-10T06:38:36-0500


import java.util.Scanner;


class Point {
	private int x;
	private int y;


	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}


	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}


	/**
	 * @param x the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}


	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}


	/**
	 * @param y the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}


};


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		System.out.print("Enter x: ");
		int x = keyBoard.nextInt();
		System.out.print("Enter y: ");
		int y = keyBoard.nextInt();
		Point p1 = new Point(x, y);


		System.out.println("\nX = " + p1.getX());
		System.out.println("Y = " + p1.getY());


		keyBoard.close();
	}
}

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