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

what is the problem in my program? #include <iostream> #include <cmath> using na

ID: 3626148 • Letter: W

Question

what is the problem in my program?


#include <iostream>
#include <cmath>

using namespace std;

// FUNCTION PROTYPE FOR test_polar
void test_polar();

// FUNCTION PROTOTYPE FOR read_point
void read_point(double & radius, double & angle);


// FUNCTION PROTOTYPE FOR degrees2radians
double degrees2radians(double angle);

// FUNCTION PROTOTYPE FOR compute_coord
void compute_coord(double radius, double radians, double & x, double & y);

// FUNCTION PROTOTYPE FOR compute_distance
double compute_distance(double x1, double y1,double x2,double y2);


// FUNCTION PROTOTYPE FOR output_point
void output_point(double x, double y);

// DO NOT MODIFY THE MAIN ROUTINE IN ANY WAY
int main()
{
double r1(0.0), a1(0.0); // Polar coord (r1, a1) of point 1
double r2(0.0), a2(0.0); // Polar coord (r2, a2) of point 2
double radians1(0.0); // Angle a1 in radians
double radians2(0.0); // Angle a2 in radians
double x1(0.0), y1(0.0); // Cartesian (x,y) coordinates of point 1
double x2(0.0), y2(0.0); // Cartesian (x,y) coordinates of point 2
double distance(0.0); // Distance between points

// Call test routine
test_polar();

// Read two points in polar coordinates
read_point(r1, a1);
read_point(r2, a2);

// Convert degrees to radians
radians1 = degrees2radians(a1);
radians2 = degrees2radians(a2);

// Compute Cartesian (x,y) coordinates
compute_coord(r1, radians1, x1, y1);
compute_coord(r2, radians2, x2, y2);

// Compute distance from point 1 to point 2
distance = compute_distance(x1, y1, x2, y2);

cout << "Distance from ";
output_point(x1, y1);
cout << " to ";
output_point(x2,y2);
cout << " = " << distance << endl;

return 0;
}

Explanation / Answer

The problem in your program is that you only have function prototypes.
There is no actual code for read_point(), degrees2radians(), etc., so the program cannot do anything when you call the functions.
You need to write that code. If you need help writing the code, I can certainly help you understand it.

However, let's say you have written the code. Since you already have the prototypes for all of the functions, you can then write the actual functions with the code after main();

...

    cout << " to ";
    output_point(x2,y2);
    cout << " = " << distance << endl;

    return 0;
} // end int main()

double degrees2radians(double angle) {

     angle=(3.14)*(angle/180.0);

     return angle;

}

...

and so on.