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>."
int Menu(void);
// displays menu of choices.
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 );
choice = Menu();
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 Menu(void){
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){
}