Question: In visual studio code: Problem 2 Deliverable: problem 2 functions.h and problem 2 functions.cpp - Write a function named Distance that takes four double arguments
In visual studio code:
Problem
Deliverable: problemfunctions.h and problemfunctions.cpp
Write a function named Distance that takes four double arguments for the x and y
coordinates of two points x y x y and returns the distance between those points
as a double. If the function is called with the coordinates of one point only, the second
points coordinates should default to the origin
Recall, the formula to compute the distance, d between two points is:
Example calls:
Distance should return the distance between the point and
the point
Distance should return the distance between the point
and the point
Write a function named OnCircle that takes the x and y coordinates of the center of a
circle as the first two parameters, the radius of the circle as the third parameter, and the
x and y coordinates of a point as the fourth and fifth parameters all doubles The
function should return if the point lies inside of the circle, if the point lies on the
circle, and if the point lies outside of the circle.
Example calls:
OnCircle should return because the point lies inside
the circle centered at with radius
Write a function named OnLine that takes the x and y coordinates all doubles of three
points x y x y x y The function should return true if the three points lie on a
straight line, and false if they do not.
Example calls:
OnLine should return true because the three points
and lie on a straight line
All three function prototypes should be included in problemfunctions.h
All three functions should be implemented in problemfunctions.cpp
A makefile and some minimal unit tests have been included in problemtests.zip.
To run the tests provided, create a directory containing only your problemfunctions.h file, your problemfunctions.cpp file, and the files extracted from the attached problemtests.zip. Then type:
make testDistance
make testOnCircle
make testOnLine
Makefile: flags stdcWall I
problemfunctions.o : problemfunctions.cpp problemfunctions.h
g $flagsc $
testDistance : testDistance.cpp problemfunctions.o
g $flags $o $@
$@
testOnCircle : testOnCircle.cpp problemfunctions.o
g $flags $o $@
$@
testOnLine : testOnLine.cpp problemfunctions.o
g $flags $o $@
$@
clean :
rm problemfunctions.o testDistance testOnCircle testOnLine
limited tests for the OnCircle function
#include
using std::cout;
using std::endl;
#include"problemfunctions.h
int main
if OnCircle
cout "Passed OnCircle test" endl;
else
cout "Failed OnCircle test" endl;
if OnCircle
cout "Passed OnCircle test" endl;
else
cout "Failed OnCircle test" endl;
if OnCircle
cout "Passed OnCircle test" endl;
else
cout "Failed OnCircle test" endl;
if OnCircle
cout "Passed OnCircle test" endl;
else
cout "Failed OnCircle test" endl;
return ;
minimal tests of the Distance function
#include
using std::cout;
using std::endl;
#include"problemfunctions.h
int main
if Distance
cout "Passed Distance test" endl;
else
cout "Failed Distance test, function returned
Distance Expected endl;
if Distance
cout "Passed Distance test" endl;
else
cout "Failed Distance test, function returned
Distance Expected endl;
if Distance
cout "Passed Distance test" endl;
else
cout "Failed Distance test, function returned
Distance Expected endl;
if Distance
cout "Passed Distance test" endl;
else
cout "Failed Distance test, function returned
Distance Expected endl;
if Distance
cout "Passed Distance test" endl;
else
cout "Failed Distance test, function returned
Distance Expected
