Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Help program this? Make use of inline functions if you can. Write a program

ID: 3860272 • Letter: C

Question

C++ Help program this? Make use of inline functions if you can.

Write a program that helps the user calculate the midpoint of a line segment in the 2D Cartesian plane.

Try to make your results as readable as possible.

Use a functionto calculate the midpoint between two 1D coordinates. The inputs (arguments) for this function should be the coordinates of the two points. The output (return value) for the function should be the calculated midpoint. This function will need to be called twice — once for the xcoordinates and once for the ycoordinates.

What is the first end-point? (3.4, 12.2) What is the second end-point? (13.4, 12.2) Thank you !! Calculating... Done. The midpoint of the line segment between (3.4, 12.2) and (13.4, 12.2) is (8.4, 12.2). Thank you for using the TMP!! Endeavor to have a voracious day!

Explanation / Answer

#include <iostream>

using namespace std;

inline double midPoint(double x1,double x2)//inline function

{

return (x1+x2)/2;

}

int main()

{

double x1,x2,y1,y2;

cout<<" Welcome to the 2D Midpoint Program ";

cout<<" What is the first end-point? (";

cin>>x1;

cout<<",";

cin>>y1;

cout<<")";

cout<<" What is the second end-point? (";

cin>>x2;

cout<<",";

cin>>y2;

cout<<")";

cout<<" Thank You!! Calculating....... Done.";

cout<<" The mid-point of the line segment between ("<<x1<<","<<y1<<") and ("<<x2<<","<<y2<<") is ";

cout<<"("<<midPoint(x1,x2)<<","<<midPoint(y1,y2)<<").";

cout<<" Thank You for using the TMP!!";

cout<<" Endeavor to have a voracious day! ";

return 0;

}

output:

Welcome to the 2D Midpoint Program

What is the first end-point? (3.4,12.2)

What is the second end-point? (13.4,12.2)

Thank You!! Calculating....... Done.

The mid-point of the line segment between (3.4,12.2) and (13.4,12.2)

is (8.4,12.2).

Thank You for using the TMP!!

Endeavor to have a voracious day!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote