I have a fairly simple C++ program problem. This program is suppose to read in two sets of coordinates (x,y) and report the magnitude, distance, and where on the plane the points lies. Here is my code so far the whole thing works except for the location function. We haven't gotten to strings yet so I don't believe that's what he wants.

// CSCI 201 Section 1
// Project 6 - Due March 4

// This program will read in two sets of coordinates and report which
// quadrant, or axis the coordinates lies in or on.
// It will also display the magnitude of each coordinate and the distance
// between the sets of coordinates.

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

// Input:
// Function:  read_coord1
// This will read the first coordinate (x,y)
void point1 (double &x1, double &y1);

// Input:
// Function:  read_coord2
// This will read the second set of coordinates (x,y)
void point2 (double &x2, double &y2);

// Function: magnitude
// This function will compute the magnitude: =sqrt(x^2 + y^2).
void magnitude (double x1, double y1, double x2, double y2,
                  double &mag1, double &mag2);

// Function: distance
// This function will compute the distance between two points.
void distance (double x1, double y1, double x2, double y2,
       double &dist);

// Function: location
// This function will display whitch axis or quadrant the coordinates lie in.
void location (double x1, double y1, double x2, double y2,
                 int &loc1, int &loc2);

// Function: report1
// This function will report the magnitude and the location of the coordinate.
void report1 (double mag1, int loc1);

// Function: report2
// This function will report the distance between the two coordinates
void report2 (double mag2, int loc2, double dist);

int main ()
{

  double x1, y1, x2, y2, mag1, mag2, dist;
  int loc1, loc2;

  point1 (x1, y1);
  magnitude (x1, y1, x2, y2, mag1, mag2);
  distance (x1, y1, x2, y2, dist);
  location (x1, y1, x2, y2, loc1, loc2);
  report1 (mag1, loc1);
  point2 (x2, y2);
  magnitude (x1, y1, x2, y2, mag1, mag2);
  distance (x1, y1, x2, y2, dist);
  location (x1, y1, x2, y2, loc1, loc2);
  report2 (mag2, loc2, dist);

return EXIT_SUCCESS;
}

void point1 (double &x1, double &y1)

{

  cout <<"Enter x coordinate:  " << endl;
  cout <<"->  ";
  cin >> x1;
  cout <<"Enter y coordinate:  " << endl;
  cout <<"->  ";
  cin >> y1;
  return;
}

void point2 (double &x2, double &y2)
{

  cout <<"Enter x coordinate:  " << endl;
  cout <<"->  ";
  cin >> x2;
  cout <<"Enter y coordinate:  " << endl;
  cout <<"->  ";
  cin >> y2;
  return;
}

void magnitude (double x1, double y1, double x2, double y2,
                  double &mag1, double &mag2)
{
  mag1 = sqrt ( (pow(x1,2))+(pow(y1,2)) );
  mag2 = sqrt ( (pow(x2,2))+(pow(y2,2)) );
  return;
}

void distance (double x1, double y1, double x2, double y2,
        double &dist)
{

  dist = sqrt( (pow((x1-x2),2)) + (pow ((y1-y2),2)) );
  return;
}


void location (double x1, double y1, double x2, double y2,
                   int &loc1, int &loc2)
{


  if (x1 == 0 && y1 != 0)
    loc1 = 5;
    else if (x1 != 0 && y1 == 0)
      loc1 = 6;
    else if (x1 == 0 && y1 == 0)
      loc1 = 7;
    else if (x1 > 0 && y1 > 0)
      loc1 = 1;
    else if (x1 < 0 && y1 > 0)
      loc1 = 2;
    else if (x1 < 0 && y1 < 0)
      loc1 = 3;
    else
      loc1 = 4;

  if (x2 == 0 && y2 != 0)
    loc2 = 'a';
    else if (x2 != 0 && y2 == 0)
      loc2 = 6;
    else if (x2 == 0 && y2 == 0)
      loc2 = 7;
    else if (x2 > 0 && y2 > 0)
      loc2 = 1;
    else if (x2 < 0 && y2 > 0)
      loc2 = 2;
    else if (x2 < 0 && y2 < 0)
      loc2= 3;
    else
      loc2 = 4;



/*  "on the x-axis" = 5;
  "on the y-axis" = 6;
  "on the origin" = 7;
  "in the first quadrant" = 1;
  "in the second quadrant" = 2;
  "in the third quadrant" = 3;
  "in the fourth quadrant" = 4; */

return;
}


void report1 (
              double mag1, char loc1)
{

  cout <<"The point lies " << loc1 << "." << endl;
  cout <<"Its magnitude is " << mag1 << "." << endl;

  return;
}

void report2 (double mag2, char loc2, double dist)
{

  cout <<"The point lies " << loc2 << "." << endl;
  cout <<"Its magnitude is " << mag2 << "." << endl;
  cout <<endl;
  cout <<"The distance between the points is " << dist << "." << endl;
  return;
}

Warning W8013 line 55: Possible use of 'x2' before definition in function main()
Warning W8013 line 55: Possible use of 'y2' before definition in function main()

Perhaps you want to pass by reference to magnitude?

Error: Unresolved external 'report1(double, int)'
Error: Unresolved external 'report2(double, int, double)'

And maybe make the prototypes match the definitions?

void report1 (double mag1, int loc1);
void report2 (double mag2, int loc2, double dist);
//...
void report1 (double mag1, char loc1)
{
   //...
}

void report2 (double mag2, char loc2, double dist)
{
   //...
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.