Question
Write a modular program, spFunctionsHWlines.cpp , with functions to perform the following: bool areParallel(parameter list as described) This function will return true if two lines,
Write a modular program, spFunctionsHWlines.cpp, with functions to perform the following:
bool areParallel(parameter list as described)
This function will return true if two lines, each line defined by two points, are parallel; otherwise, it will return false.
bool arePerpendicular(parameter list as described)
This function will return true if two lines, each line defined by two points, are perpendicular; otherwise, it will return false.
double calculateDistance(parameter list as described)
This function will calculate and return the distance between two points.
bool calculateIntersection(parameter list as described)
This function will return true if two lines, each line defined by two points, intersect; otherwise, it will return false. If the two lines intersect, the point at which they intersect should be passed back to the calling function via reference parameters.
void calculateMidpoint(parameter list as described)
This function should calculate the midpoint of a line segment defined by two points. Since the midpoint consists of two values, these values should be passed back to the calling function via reference parameters.
bool calculateSlope(parameter list as described)
This function will return true if the slope of a line, defined by two points, is defined; otherwise, it will return false. If the slope is defined, the slope should be passed back to the calling function via a reference parameter.
void displayEquation(parameter list as described)
This function will display the equation of a line, defined by two points, to the screen in the standard format, y = mx + b, where m is the slope and b is the y-intercept.
void getPoint(parameter list as described)
This function should get a point, (x, y), from the user and pass the values for both x and y back to the calling function using reference parameters.
bool isOnLine(parameter list as described)
This function will determine if a point, (x, y), is on a line defined by two other points. If the point is on the line, the function should return true, otherwise, it should return false.
bool isVertical(parameter list as described)
This function should return true if a line, defined by two points, is vertical, otherwise, it should return false.
The points could contain decimal values which means the variables storing these values should be of type double. Recall that floating-point numbers should not be compared using the == relational operator; instead, use an epsilon comparison with a tolerance of 0.0000001.
When establishing parameter lists which include multiple points, students often implement an ordering of all the x values together followed by all of the y values, e.g. x1, x2, y1, y2. A better ordering would be to group the x and y values of a point together, e.g. x1, y1, x2, y2.
Be sure to include driver code in function main to test these functions thoroughly. Recall that testing functions using driver code calls for the use of hard-coded values rather than prompted values; that will work for all of these functions except getPoint() which requires user input values for testing.
The file containing this program should be named spFunctionsHWlines.cpp.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started