Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A point in the x-y plane is represented by its x-coordinate and y-coordinate. De

ID: 3656141 • Letter: A

Question

A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design the class Point that can store and process a point in the x-y plane. You should then perform operation on a point, such as showing the point, setting the coordinates of the point, printing the coordinates of the point, returning the x-coordinate, and returning the y-coordinate. Also, write a test program to test various operation on a point.

Explanation / Answer

001 import java.util.*; 002 003 public class Tester 004 { 005 static Scanner console = new Scanner(System.in); 006 public static void main(String[] args) 007 { 008 // Declare variables 009 int loopDecision, xC, yC, rC; 010 011 // Loop statement 012 System.out.println("Enter 1 to insert your own values. " + 013 "Enter 2 to use preset values."); 014 loopDecision = console.nextInt(); 015 016 /* If 1 is chosen then it goes into the if loop. 017 * In the if loop the user will be able to set their 018 * own coordinates and radius. They will then get the 019 * area of the circle and the circumference. */ 020 if(loopDecision == 1) 021 { 022 // Ask user to input values 023 System.out.println("Enter a number 1-10 for the X coordinate."); 024 xC = console.nextInt(); 025 System.out.println("Enter a number 1-10 for the Y coordinate."); 026 yC = console.nextInt(); 027 System.out.println("Enter the radius."); 028 rC = console.nextInt(); 029 System.out.println(); 030 031 // Set the Circle class. 032 Circle p = new Circle(xC, yC, rC); 033 034 // Display their entered values 035 System.out.println("X coordinate = " + p.getX()); 036 System.out.println("Y coordinate = " + p.getY()); 037 System.out.println(); 038 039 // These two for loops display the values on the side and bottom 040 for(int i = 10; i > 0; i--) 041 { 042 System.out.println(i); 043 } 044 for(int i = 1; i 0; i--) 072 { 073 System.out.println(i); 074 } 075 for(int i = 1; i 0; i--) 099 { 100 System.out.println(i); 101 } 102 for(int i = 1; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote