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

My program wont work it say the funtion void distance already has a body, but th

ID: 3686988 • Letter: M

Question

My program wont work it say the funtion void distance already has a body, but the program has to be created by input, caluction, and output results. How do i fix the function that already has a body.

#include <iostream>

#include <cmath>

#include <iomanip>

using namespace std;

void distance(double&, double&, double&, double&, double&);

int main()

{

                double x1, y1, x2, y2, d;

                cout << " What are the cooridnates for (x1,y1)? ";

                cin >> x1 >> y1;

                cout << "What are the coordinates for (x2, y2)? ";

                cin >> x2 >> y2;

                system("pause");

                return 0;

}

void distance(double& x1, double& y1, double& x2, double& y2, double& d)

{

                d = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

                return;

}

void distance(double& x1, double& y1, double& x2, double& y2, double& d)

{

                {

                                cout << "The distance of the two point are : " << d << endl;

                                return;

                }

}

  

Explanation / Answer

#include <iostream>

#include <cmath>

#include <iomanip>

using namespace std;

void distance(double, double, double, double, double&);
void printDistance(double d);

int main()

{

                double x1, y1, x2, y2, d;

                cout << " What are the cooridnates for (x1,y1)? ";

                cin >> x1 >> y1;

                cout << "What are the coordinates for (x2, y2)? ";

                cin >> x2 >> y2;

                distance(x1, y1, x2, y2, d);

                printDistance(d);

               system("pause");

                return 0;

}

void distance(double x1, double y1, double x2, double y2, double& d)

{

                d = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

                return;

}

void printDistance(double d){

       cout << "The distance of the two point are : " << d << endl;
        return;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote