I am having trouble, i am trying to make a program read in 3 points and calculate the 3 things listed in the program, but i cant seem to get the sideA-C to get calculated out without overloading the sqrt function. The functions given above main have to be used the way they are given, more can be added, but the ones givens have to be used. Please help, i know i dont yet have the display function finished or even started, but im not there yet.

``````#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;

void ProgrammerNote(void);
// displays the message "Programmed by <type your name here>."

double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3);
// computes the length of the line between two points, p1, p2.
// L = sqrt( (x2-x1)^2 + (y2-y1)^2 )

double ComputePerimeter(double sideA, double sideB, double sideC);
// computes the triangle's perimeter P = A + B + C.

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC);
// computes the triangle's area by using the formula:
// A = sqrt( S(S-A)(S-B)(S-C) ), where S is the semi perimeter, S = (A + B + C) / 2.

void ReadPoint(string prompt, int& x, int& y);
// reads in the x,y coordinates of a point.

void DisplayMeasure(string prompt, double value);
// displays the value along with its prompt. This function is used to display all
// calculated measures,
// i.e. perimeter, area and length.

void main (void){

int x1 = 0, y1 = 0,
x2 = 0, y2 = 0,
x3 = 0, y3 = 0,
choice = 0;

double Length = 0, Area = 0, Perimeter = 0,
sideA = 0, sideB = 0, sideC = 0;

ProgrammerNote();

ReadPoint("Enter point 1 [x y]: ", x1, y1);
ReadPoint("Enter point 2 [x y]: ", x2, y2);
ReadPoint("Enter point 3 [x y]: ", x3, y3);

sideA = sqrt( (x2-x1)^2 + (y2-y1)^2 );
sideB = sqrt( (x3-x2)^2 + (y3-y2)^2 );
sideC = sqrt( (x3-x1)^2 + (y3-y1)^2 );

if (choice == 1){
Perimeter = ComputePerimeter(sideA, sideB, sideC);
}
else if (choice == 2){
Area = ComputeArea(Perimeter, sideA, sideB, sideC);
}
else if (choice == 3){
Length = ComputeLength(x1, y1, x2, y2, x3, y3);
}
}

void ProgrammerNote(void){
cout << "Programmed by Paul Jones" << endl << endl;
}

void ReadPoint(string prompt, int& x, int& y){
cout << prompt;
cin >> x >> y;
}

int choice;
cout << setw(5) << "1. Compute Perimeter" << endl
<< setw(5) << "2. Compute Area" << endl
<< setw(5) << "3. Compute Side Length" << endl
<< setw(5) << "4. Quit" << endl;
cin >> choice;
return choice;
}
double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3){
char side;
double Length;
cout << "Which side would you like [A]p1-p2 [B]p2-p3 [C]p1-p3: ";
cin.get(side);
while (side != '/n'){
char( toupper(side) );
cin.get(side);
}

if (side == 'A'){
Length = sqrt( (x2-x1)^2 + (y2-y1)^2 );
return L;
}
if (side == 'B'){
Length = sqrt( (x3-x2)^2 + (y3-y2)^2 );
return L;
}
if (side == 'C'){
Length = sqrt( (x3-x1)^2 + (y3-y1)^2 );
return Length;
}
}
double ComputePerimeter(double sideA, double sideB, double sideC){
double P;
P = sideA + sideB + sideC;
return P;
}

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC){
double S = 0, Area = 0;
// S is the semi perimeter
S = Perimeter / 2;

Area = sqrt( S(S-sideA)(S-sideB)(S-sideC) );
return Area;
}

void DisplayMeasure(string prompt, double value){

}``````

Updated version, still same problem, just now everything but the sqrt functions is fixed and done, just need help on how to fix the overloaded sqrt function...

This program brings up these errors:

Error 1 error C2668: 'sqrt' : ambiguous call to overloaded function c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 52
Error 2 error C2668: 'sqrt' : ambiguous call to overloaded function c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 53
Error 3 error C2668: 'sqrt' : ambiguous call to overloaded function c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 54
Error 4 error C2668: 'sqrt' : ambiguous call to overloaded function c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 112
Error 5 error C2668: 'sqrt' : ambiguous call to overloaded function c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 116
Error 6 error C2668: 'sqrt' : ambiguous call to overloaded function c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 120
Error 7 error C2064: term does not evaluate to a function taking 1 arguments c:\documents and settings\smallpaul\desktop\c++\program4\program4\program4.cpp 135

``````#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;

void ProgrammerNote(void);
// displays the message "Programmed by <type your name here>."

double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3);
// computes the length of the line between two points, p1, p2.
// L = sqrt( (x2-x1)^2 + (y2-y1)^2 )

double ComputePerimeter(double sideA, double sideB, double sideC);
// computes the triangle's perimeter P = A + B + C.

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC);
// computes the triangle's area by using the formula:
// A = sqrt( S(S-A)(S-B)(S-C) ), where S is the semi perimeter, S = (A + B + C) / 2.

void ReadPoint(string prompt, int& x, int& y);
// reads in the x,y coordinates of a point.

void DisplayMeasure(string prompt, double value);
// displays the value along with its prompt. This function is used to display all
// calculated measures,
// i.e. perimeter, area and length.

void main (void){

int x1 = 0, y1 = 0,
x2 = 0, y2 = 0,
x3 = 0, y3 = 0,
choice = 0;

double Length = 0, Area = 0, Perimeter = 0,
sideA = 0, sideB = 0, sideC = 0, value = 0;

ProgrammerNote();

ReadPoint("Enter point 1 [x y]: ", x1, y1);
ReadPoint("Enter point 2 [x y]: ", x2, y2);
ReadPoint("Enter point 3 [x y]: ", x3, y3);

sideA = sqrt( (x2-x1)^2 + (y2-y1)^2 );
sideB = sqrt( (x3-x2)^2 + (y3-y2)^2 );
sideC = sqrt( (x3-x1)^2 + (y3-y1)^2 );

if (choice == 1){
Perimeter = ComputePerimeter(sideA, sideB, sideC);
}
else if (choice == 2){
Area = ComputeArea(Perimeter, sideA, sideB, sideC);
}
else if (choice == 3){
Length = ComputeLength(x1, y1, x2, y2, x3, y3);
}

if (Perimeter != 0) {
value = Perimeter;
DisplayMeasure("Perimeter: ", value);
}
else if (Area != 0) {
value = Area;
DisplayMeasure("Area: ", value);
}
else if (Length != 0) {
value = Length;
DisplayMeasure("Length: ", value);
}

}//end main()

void ProgrammerNote(void){
cout << "Programmed by Paul Jones" << endl << endl;
}

void ReadPoint(string prompt, int& x, int& y){
cout << prompt;
cin >> x >> y;
}

int choice;
cout << setw(5) << "1. Compute Perimeter" << endl
<< setw(5) << "2. Compute Area" << endl
<< setw(5) << "3. Compute Side Length" << endl
<< setw(5) << "4. Quit" << endl;
cin >> choice;
return choice;
}
double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3){
char side;
double Length;
cout << "Which side would you like [A]p1-p2 [B]p2-p3 [C]p1-p3: ";
cin.get(side);
while (side != '/n'){
char( toupper(side) );
cin.get(side);
}

if (side == 'A'){
Length = sqrt( (x2-x1)^2 + (y2-y1)^2 );
return Length;
}
if (side == 'B'){
Length = sqrt( (x3-x2)^2 + (y3-y2)^2 );
return Length;
}
if (side == 'C'){
Length = sqrt( (x3-x1)^2 + (y3-y1)^2 );
return Length;
}
}
double ComputePerimeter(double sideA, double sideB, double sideC){
double P;
P = sideA + sideB + sideC;
return P;
}

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC){
double S = 0, Area = 0;
// S is the semi perimeter
S = Perimeter / 2;

Area = sqrt( S(S-sideA)(S-sideB)(S-sideC) );
return Area;
}

void DisplayMeasure(string prompt, double value){
cout << prompt << value;
}``````

You will have to replace parts like

``sideA = sqrt( (x2-x1)^2 + (y2-y1)^2 );``

to

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

In C++ `^` does not denote power of.

Wow, im an idiot, Thank you, lol, we just learned this about 2 weeks ago, :rolleyes:

Now its giving me these errors:

Error 1 error C2668: 'pow' : ambiguous call to overloaded function 52
Error 2 error C2668: 'pow' : ambiguous call to overloaded function 52
Error 3 error C2668: 'pow' : ambiguous call to overloaded function 53
Error 4 error C2668: 'pow' : ambiguous call to overloaded function 53
Error 5 error C2668: 'pow' : ambiguous call to overloaded function 54
Error 6 error C2668: 'pow' : ambiguous call to overloaded function 54
Error 7 error C2668: 'sqrt' : ambiguous call to overloaded function 112
Error 8 error C2668: 'sqrt' : ambiguous call to overloaded function 116
Error 9 error C2668: 'sqrt' : ambiguous call to overloaded function 120
Error 10 error C2064: term does not evaluate to a function taking 1 arguments 135

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC){
double S = 0, Area = 0;
// S is the semi perimeter
S = Perimeter / 2;

Area = sqrt( S(S-sideA)(S-sideB)(S-sideC) );
return Area;
}

The last error was because you have not used the multiplication operator. In C/C++ there is no implicit multiplication. `AB` is not equal to `A * B` Replace that line with

``Area = sqrt( S*(S-sideA)*(S-sideB)*(S-sideC) );``

As for the other errors, if you have included <cmath> there shouldn't be any problem. If you encounter the same problems, post the corrected code again.

Ok, i fixed the last one by changing it to this:

Area = sqrt( S * ( (S-sideA) * (S-sideB) * (S-sideC) ) );

But i still have those other 9 errors, :sad:

lol, thank you, fixed that last one before i saw the post, :mrgreen:

But i have cmath included as you can see here (but it still brings up the errors):

``````#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;

void ProgrammerNote(void);
// displays the message "Programmed by <type your name here>."

double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3);
// computes the length of the line between two points, p1, p2.
// L = sqrt( (x2-x1)^2 + (y2-y1)^2 )

double ComputePerimeter(double sideA, double sideB, double sideC);
// computes the triangle's perimeter P = A + B + C.

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC);
// computes the triangle's area by using the formula:
// A = sqrt( S(S-A)(S-B)(S-C) ), where S is the semi perimeter, S = (A + B + C) / 2.

void ReadPoint(string prompt, int& x, int& y);
// reads in the x,y coordinates of a point.

void DisplayMeasure(string prompt, double value);
// displays the value along with its prompt. This function is used to display all
// calculated measures,
// i.e. perimeter, area and length.

void main (void){

int x1 = 0, y1 = 0,
x2 = 0, y2 = 0,
x3 = 0, y3 = 0,
choice = 0;

double Length = 0, Area = 0, Perimeter = 0,
sideA = 0, sideB = 0, sideC = 0, value = 0;

ProgrammerNote();

ReadPoint("Enter point 1 [x y]: ", x1, y1);
ReadPoint("Enter point 2 [x y]: ", x2, y2);
ReadPoint("Enter point 3 [x y]: ", x3, y3);

sideA = sqrt( pow(x2-x1,2) + pow(y2-y1,2) );
sideB = sqrt( pow(x3-x2,2) + pow(y3-y2,2) );
sideC = sqrt( pow(x3-x1,2) + pow(y3-y1,2) );

if (choice == 1){
Perimeter = ComputePerimeter(sideA, sideB, sideC);
}
else if (choice == 2){
Area = ComputeArea(Perimeter, sideA, sideB, sideC);
}
else if (choice == 3){
Length = ComputeLength(x1, y1, x2, y2, x3, y3);
}

if (Perimeter != 0) {
value = Perimeter;
DisplayMeasure("Perimeter: ", value);
}
else if (Area != 0) {
value = Area;
DisplayMeasure("Area: ", value);
}
else if (Length != 0) {
value = Length;
DisplayMeasure("Length: ", value);
}

}//end main()

void ProgrammerNote(void){
cout << "Programmed by Paul Jones" << endl << endl;
}

void ReadPoint(string prompt, int& x, int& y){
cout << prompt;
cin >> x >> y;
}

int choice;
cout << setw(5) << "1. Compute Perimeter" << endl
<< setw(5) << "2. Compute Area" << endl
<< setw(5) << "3. Compute Side Length" << endl
<< setw(5) << "4. Quit" << endl;
cin >> choice;
return choice;
}
double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3){
char side;
double Length;
cout << "Which side would you like [A]p1-p2 [b]p2-p3 [C]p1-p3: ";
cin.get(side);
while (side != '/n'){
char( toupper(side) );
cin.get(side);
}

if (side == 'A'){
Length = sqrt( (x2-x1)^2 + (y2-y1)^2 );
return Length;
}
if (side == 'B'){
Length = sqrt( (x3-x2)^2 + (y3-y2)^2 );
return Length;
}
if (side == 'C'){
Length = sqrt( (x3-x1)^2 + (y3-y1)^2 );
return Length;
}
}
double ComputePerimeter(double sideA, double sideB, double sideC){
double P;
P = sideA + sideB + sideC;
return P;
}

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC){
double S = 0, Area = 0;
// S is the semi perimeter
S = Perimeter / 2;

Area = sqrt( S * ( (S-sideA) * (S-sideB) * (S-sideC) ) );
return Area;
}

void DisplayMeasure(string prompt, double value){
cout << prompt << value;
}``````

i think i mightve figured it out, ill post again if i didnt get it, thanks again!

Read my signature -- don't use `void main` .

``````double ComputeLength(int x1, int y1, int x2, int y2, int x3, int y3){
char side;
double Length;
cout << "Which side would you like [A]p1-p2 [b]p2-p3 [C]p1-p3: ";
cin.get(side);
while (side != '/n'){
char( toupper(side) );
cin.get(side);
}``````

You used a `/` instead of a `\` when you wrote `while (side != '/n')` (should be `'\n'` ).

The reason you're getting all those errors about "ambiguous call" is because the numbers you're passing to `pow` and `sqrt` don't match any of the overloaded functions -- you'll need to use casts to make the compiler errors go away.

Hope this helps

I finally got itall done, thanks for the help!

``````#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;

void ProgrammerNote(void);
// displays the message "Programmed by <type your name here>."

double ComputeLength(int x1, int y1, int x2, int y2);
// computes the length of the line between two points, p1, p2.
// L = sqrt( (x2-x1)^2 + (y2-y1)^2 )

double ComputePerimeter(double sideA, double sideB, double sideC);
// computes the triangle's perimeter P = A + B + C.

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC);
// computes the triangle's area by using the formula:
// A = sqrt( S(S-A)(S-B)(S-C) ), where S is the semi perimeter, S = (A + B + C) / 2.

void ReadPoint(string prompt, int& x, int& y);
// reads in the x,y coordinates of a point.

void DisplayMeasure(string prompt, double value);
// displays the value along with its prompt. This function is used to display all
// calculated measures,
// i.e. perimeter, area and length.

void main (void){

int x1 = 0, y1 = 0,
x2 = 0, y2 = 0,
x3 = 0, y3 = 0,
choice = 0;

ProgrammerNote();

cout << endl;

ReadPoint("Enter point 1 [x y]: ", x1, y1);
ReadPoint("Enter point 2 [x y]: ", x2, y2);
ReadPoint("Enter point 3 [x y]: ", x3, y3);

do{
double Length = 0, Area = 0, Perimeter = 0,
sideA = 0, sideB = 0, sideC = 0;

cout << endl;

sideA = sqrt( pow(double(x2-x1),2) + pow(double(y2-y1),2) );
sideB = sqrt( pow(double(x3-x2),2) + pow(double(y3-y2),2) );
sideC = sqrt( pow(double(x3-x1),2) + pow(double(y3-y1),2) );

if (choice == 1){
Perimeter = ComputePerimeter(sideA, sideB, sideC);
DisplayMeasure("Perimeter: ", Perimeter);
}
if (choice == 2){
Perimeter = sideA + sideB + sideC;
Area = ComputeArea(Perimeter, sideA, sideB, sideC);
DisplayMeasure("Area: ", Area);
}
if (choice == 3){
char side;
double Length = 0;
cout << "Which side would you like [A]p1-p2 [b]p2-p3 [C]p1-p3: ";
cin >> side;

if (side == 'A' || side == 'a'){
Length = ComputeLength(x1, y1, x2, y2);
DisplayMeasure("SideA: ", Length);
}

else if (side == 'B' || side == 'b'){
Length = ComputeLength(x2, y2, x3, y3);
DisplayMeasure("SideB: ", Length);
}

else if (side == 'C' || side == 'c'){
Length = ComputeLength(x1, y1, x3, y3);
DisplayMeasure("SideC: ", Length);
}
}
}while (choice != 4);
cout << endl;
}//end main()

void ProgrammerNote(void){
cout << "Programmed by Paul Jones" << endl << endl;
}// end ProgrammerNote()

void ReadPoint(string prompt, int& x, int& y){
cout << prompt;
cin >> x >> y;

int choice;
cout << endl;
cout << setw(5) << " " << "1. Compute Perimeter" << endl
<< setw(5) << " " << "2. Compute Area" << endl
<< setw(5) << " " << "3. Compute Side Length" << endl
<< setw(5) << " " << "4. Quit" << endl;
cout << "Enter choice [1-4]: ";
cin >> choice;
return choice;
double ComputeLength(int x1, int y1, int x2, int y2){
double Length;

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

return Length;

}// end ComputeLength()
double ComputePerimeter(double sideA, double sideB, double sideC){
double P;
P = sideA + sideB + sideC;
return P;
}// end ComputePerimeter()

double ComputeArea(double Perimeter, double sideA, double sideB, double sideC){
double S = 0, Area = 0;
// S is the semi perimeter
S = Perimeter / 2;

Area = sqrt( S * ( (S-sideA) * (S-sideB) * (S-sideC) ) );
return Area;
}// end ComputeArea()

void DisplayMeasure(string prompt, double value){
cout << prompt << value << endl;

}//end DisplayMeasure()``````
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.