Question: Please use C + + , 3 Struct Data Types Use program Distance for Exercise 3 . / / Program Distance gets user inputs for

Please use C++,
3 Struct Data Types
Use program Distance for Exercise 3.
// Program Distance gets user inputs for the x, y coordinates
// of two points, then calculates the distance between the two
// points and prints the result.
#include
#include
using namespace std;
struct Point
{
double x;
double y;
};
void printPoint( Point p )
{
cout.precision(1);
cout fixed showpoint;
cout "(" p.x "," p.y ")";
return;
}
Point readPoint()
{
Point p;
cout "Enter point [x y]: ";
cin >> p.x >> p.y;
return p;
}
int main()
{
Point p1, p2;
p1= readPoint();
p2= readPoint();
cout "The distance between ";
printPoint(p1);
cout " and ";
printPoint(p2);
cout " is " PointDistance(p1,p2) endl;
return 0;
}
Exercise 3:
Create a function called PointDistance that calculates distance between the two points. It should be a
double value-returning function that accepts two parameters both of type Point. Dont forget to use the
sqrt() function.
Run the program and enter the results for the following data. In your lab report, also include the
modified .cpp file.
 Please use C++, 3 Struct Data Types Use program Distance for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!