0

Hi, I'm having a problem with this program.

When I choose an option, all the program does is output three random numbers with letters in them. Do any of you know what my problem is? Any help is appreciated.

Thanks for taking the time to read my program.

- bookmark.

```
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
const double PI = 3.14159265358979323846;
double s;
bool die( const string & msg);
bool getDouble( double & value, const string & prompt );
char userChoice;
double circleCircumference( double radius );
double circleArea( double radius );
double trianglePerimeter( double side );
double triangleArea( double side );
double squarePerimeter( double side );
double squareArea( double side );
double hexagonPerimeter( double side );
double hexagonArea( double side );
int main(){
char j, c, C, t, T, h, H, q, Q;
cout << "C: analyze circle" << endl
<< "T: analyze equilateral triangle" << endl
<< "S: analyze square" << endl
<< "H: analyze regular hexagon" << endl
<< "Q: quit the program" << endl;
cin >> j;
cout << endl;
while(cin>>j){
if (j == 'c' || j == 'C'){
cout << getDouble << endl;
cout << circleCircumference<< endl;
cout << circleArea << endl;
}
else if( j == 't' || j == 'T'){
cout << getDouble << endl;
cout << trianglePerimeter << endl;
cout << triangleArea << endl;
}
else if(j == 's' || j == 'S'){
cout << getDouble << endl;
cout << squarePerimeter << endl;
cout << squareArea << endl;
}
else if(j =='h' || j == 'H'){
cout << getDouble << endl;
cout << hexagonPerimeter << endl;
cout << hexagonArea << endl;
}
else {
exit(EXIT_SUCCESS);
system("pause");
}
}
}
bool die(const string & message){
cout << message << endl;
exit(EXIT_FAILURE);
}
bool getDouble( double & s, const string & prompt){
cout << "What is the length of your side or radius?" << endl;
if(cin >> s) {
s = s;
return true; }
else{
return false;}
}
double circleCircumference( double r){
s = r;
cin >> r;
if( r < 0){
bool die("radius is negative");
}
else {
cout << "The circumference of the circle is " << 2 * PI * r << endl;
return r;
}
}
double circleArea( double r ){
double A;
s = r;
A = PI * (r*r);
if( r < 0){
bool die("radius is negative");
}
else {
cout << " The area of the circle is " << A << endl;
return r;
}
}
double trianglePerimeter( double l){
s = l;
double tP;
tP = 3*l;
if(s<0){
bool die("side is negative"); }
else {
cout << "The Perimeter of the triangle is " << tP << endl;}
return tP;
}
double triangleArea( double m){
s = m;
double tA;
tA = ((sqrt(3.0)) / 4 ) * m * m;
if (s<0){
bool die("side is negative") ;}
else{
cout << "The area of the triangle is " << tA << endl;
return tA;
}
}
double squarePerimeter( double n){
s = n;
double sP;
sP = 4*n;
if (n<0){
bool die("side is negative");}
else{
cout << "The perimeter of the square is " << sP << endl;
return sP;
}
}
double squareArea(double o){
s = o;
double sA;
sA = o * o;
if (o<0){
bool die ("side is negative");}
else{
cout << "The perimeter of the square is " << sA << endl;
} return sA;}
double hexagonPerimeter(double p){
s = p;
double hP;
hP = 6 * p;
if( p < 0){
bool die("side is negative");}
else {
cout << "The perimeter of the hexagon is " << hP << endl;
} return hP;
}
double hexagonArea(double q){
s = q;
double hA;
hA = 6 * ((sqrt(3.0)) / 4 ) * q * q;
if ( q < 0 ){
bool die ( "side is negative");}
else{
cout << "The perimeter of the hexagon is " << hA << endl;
}
return hA;
}
```