Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ use namespace std; Here is what it looks like after you done 5. Create a point structure for modeling points in the xy-plane. Then,

C++
use namespace std;
image text in transcribed
image text in transcribed
Here is what it looks like after you done
image text in transcribed
image text in transcribed
5. Create a point structure for modeling points in the xy-plane. Then, write a menu-driven C++ program that uses variables of type point to perform a variety of tasks involving points in the xy plane. Your program should be modular and must contain these functions: - dist - this function will receive two points and calculate and return the distance between the Points. - slope - this function will receive two points and calculate and return the slope of the line connecting two points, if it exists. This function should have a bool reference parameter that will return a value to the user indicating whether the slope is defined or not. - midpoint - this function will receive two points and calculate and return the midpoint of the line segment between two points. - equation - this function will receive two points and display the equation of the line passing through two points. - collinear - this function will receive three points and determine if three points are collinear. If the points are collinear, this function should return true; otherwise, it should return false. - readpt - this function will read a single point entered by the user in standard point "format" (for example "(4,3)") into a point variable and then return the point. - showPt - this function will receive a point and then display the point in standard point "format" (for example "(4,3)"). Your function main should repeatedly display a menu of the above point manipulation tasks, read the user's task selection, and then call the appropriate function(s) from above to perform the selected task and display the result, until the user selects to exit the program. Notes and suggestions: - When the slope is not defined, function slope can return any value for the slope - the bool parameter will be set appropriately so that the calling function will know not to use the returned - In function collinear, use function slope to determine its result. When checking for equality of two slopes, do not use the "=" operator on the float values - instead, determine if the absolute value of the float values are smaller than a threshold value (something small, like 0.000001 ). Algebra Topics Review: - Slope of the line between (a,b) and (c,d),m=cadb provided a=c; slope undefined for vertical lines. - Distance between (a,b) and (c,d):D=(ca)2+(db)2 - Midpoint between (a,b) and (c,d):M=(2a+c,2b+d) - The equation of a non-vertical line passing through (a,b) and (c,d) is given by y=mx+(bma) where m is the slope of the line. - The equation of a vertical line passing through (a,b) and (a,d) is given by x=a where the slope of the line is undefined. Here is output from a sample run of the program (user input in bold): POINTLAND What do you want to do? 1. - Find distance between two points 2 - Find slope 3 - Find a midpoint 4 - Find an equation of a line 5 - Determine if three points are collinear 6 - Exit Selection 1 Enter point 1: (1,1) Enter point 2:(4,5) Distance =5 POINTLIAND What do you want to do? 1 - Find distance between two points 2 - Find slope 3 - Find a midpoint 4 - Find an equation of a line 5 - Determine if three points are collinear 6 - Exit Selection 2 Enter point 1: (2,3) Enter point 2 : (3,5) Slope =2 POINTLAND What do you want to do? 1 - Find distance between two points 2 - Eind slope 3 - Eind a midpoint 4 - Find an equation of a line 5 - Determine if three points are collinear 6 - Exit Selection 3 Enter point 1: (1,2) Enter point 2:(3,4) Midpoint=(2,3) POINTLAND What do you want to do? 1 - Find distance between two points 2 - Find slope 3 - Find a midpoint 4 - Find an equation of a line 5 - Determine if three points are collinear 6 - Exit Selection 4 Entex point 1: (0,2) Enter point 2: (1,5) Equation: y=3x+2 POINTLIAND What do you want to do? 1 - Find distance between two points 2 - Find slope 3 - Find a midpoint 4 - Find an equation of a line 5 - Determine if three points are collinear 6 - Exit Selection 5 Enter point 1: (0,0) Enter point 2: (1,1) Enter point 3:(2,3) points are not collinear POINILAND What do you want to do? 1 - Find distance between two points 2 - Eind slope 3 - Find a midpoint 4 - Find an equation of a line 5 - Determine if three points are collinear 6 - Exit Selection 5 Entor point 1: (0,2) Enter point 2: (3,4) Enter point 3: (6,6) points are collinear POINTLAND What do you want to do? 1 - Find diatance between two pointa 2 - Find slope 3. - Find a midpoint 4 - Eind an equation of a line. 5 - Dotermine if three points are collinear 6 - Exit Selection 6

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

Students also viewed these Databases questions

Question

Define middleware. What are the three categories of middleware?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago