Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
9.8k views
in Computer by (49.9k points)
closed by

The coordinates of a point P on a two-dimensional plane can be represented by P(x, y) with x as the x-coordinate and y as the y-coordinate. The coordinates of the midpoint of two points P1(x1, y1) and P2(x2, y2) can be calculated as P(x, y) where:

Design a class Point with the following details: Class name: Point 

Data Members/instance variables: 

x: stores the x-coordinate 

y: stores the y-coordinate 

Member functions:

Point (): constructor to initialize x = 0, y = 0 

void readpoint (): accepts the coordinates x and y of a point Point midpoint (Point A, Point B): 

calculates and returns the midpoint of the two points A and B 

void displaypoint (): displays the coordinates of a point 

Specify the class Point giving details of the constructor (), member functions void readpoint ( ), Point midpoint (Point, Point) and void displaypoint () along with the main () function to create an object and call the functions accordingly to calculate the midpoint between any two given points.

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

import java.io.*; 

class Point 

int x; 

inty; 

public Point () 

x = 0; 

y = 0; 

public void read point () throws IOException 

Buffered Reader br = new BufferedReader(new 

InputStreamReader(Systemin); 

System.out.println("Enter the value of x''); 

x = Integer.parselnt (br. readLine()); 

System.out.printing'Enter the value of y "); 

y = Integer.parselnt(br. readLine ( )); 

public Point midpoint(Point A, Point B) 

x = (A.x+B.x)/2; 

y = (A.y + B.y)/2;

public void displaypoint() 

System.out.println(x); 

System. out.println(y); 

public void main() 

Point obj 1 = new Point(); 

obj1.readpoint(); 

Point obj 2 = new Point(); o

bj2.readpoint(); 

Point obj 3 = new Point(); 

Point obj4 = obj3.midpoint(obj 1, obj2); 

obj4.displayPoint(); 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...