So I can't figure out how to change my result into an exact decimal.
Code:
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#define Pi double(3.14159)
using namespace std;
void Switch(double x, double y, double z, char Type)
{
int h = 0;
switch (Type)
{
case 'e':
cout << "\n\tThe Area of the Equilateral is = " << 1.0/2.0 * x * sqrt(x*x -(x/2)*(x/2));
break;
case 's':
cout << "\n\tThe Area of the Square is = " << x * x;
break;
case 'p':
h =tan(54 * Pi/180);
cout << "\n\tThe Height is = " << h;
break;
default:
cout << "\n\tinvalid entry";
}
}
My problem is that the tan function returns 1 instead of like 1.37etc...
I tried making them all into double by puting .0 at end of each number, i.e. 180.0. That didn't work
I also tried removing the #define Pi and putting instead in my code, double Pi = 3.14159. That didn't work either.
Any simple suggestions? I am only in a beginning c++ class mind you so the simpler the suggestion the better.