Question: Input the coordinates of two points in the Cartesian coordinate system. Calculate the distance between the points and the midpoint between them. The program will
Input the coordinates of two points in the Cartesian coordinate system. Calculate the distance between the points and the midpoint between them. The program will be submitted in Java and also in C++. Also, include an appropriate algorithm. Input: Accept 4 real numbers from the user, representing coordinates x_1, y_1, x_2, and y_2. Processing: Note that the C++ cmath library includes two useful functions, pow and squareroot . Formulas: distance: d = squareroot (x_2 - x_1)^2 + (y_2 - y_1)^2 midpoint: (x_1 + x_2/2, y_1 + y_2/2) Output: Print appropriate labels, the original points, the distance, and the midpoint. Print the original points and the midpoint with one decimal position: print the distance with two decimal positions. Sample output (you may change the layout): Points: (3.0, 2.5) (-1.0, 4.0) Distance: 4.27 Midpoint: (1.0, 3.3)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
