Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions