Hello everyone. Home help = homework help :) can't change it now
I'm running into an error, expected initialize before "int menu()"
I have been playing around with it for a bit but I have not figured out how to get rid of the error.
When I think I got rid of the error, I ended up getting 40 new errors on the next compile. As of right now I am using quincy and with this code it is only showing the one error.
I'm aware there might actually be lots of more errors that are not showing up yet.
My assignment link is here:
http://faculty.cs.niu.edu/~byrnes/csci240/pgms/240pgm5.htm
Here is code:
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
#define PI 3.14159 //defined constant to be used in calculations
int choice, radius, length, width, height;
//int getValue(string prompt, int x, int y)
int menu()
{
int choice;
cout << endl << endl << "******Surface Area Calculator******" << endl;
cout << "1) Sphere " << endl;
cout << "2) Cone " << endl;
cout << "3) Reactangular Prism " << endl;
cout << "4) Pyramid " << endl;
cout << "5) Quit " << endl;
cout << "***********************************" << endl;
cin >> choice;
while (choice<1||choice>5)
{
cout << "ERROR! Enter an integer value from 1 to 5" << endl;
cin >> choice;
}
return choice;
}
int getValue (string promt, int x, int y)
{
int variable;
cout << promt << "(" << x << "-" << y << ")";
cin >> variable;
while (variable < x || variable > y )
{
cout << "ERROR! Enter an integer value from " << x << " to " << y << endl;
cin >> variable;
}
return variable;
}
float calcSphere (int radius)
{
float SA;
SA = (4 * PI * (radius * radius)); //calculations
return SA;
}
float calcCone (int radius)
{
float SA;
SA = ( PI * radius * length ) + ( PI * (radius * radius)); //calculations
return SA;
}
float calcPrism(int radius)
{
float SA;
SA = ( 2 * length * width ) + ( 2 * width * height ) + ( 2 * length * height ); //calculations
return SA;
}
float calcPyramid(int radius)
{
float SA;
SA = ( 2 * length * height ) + (length * length); //calculations
return SA;
}
int main()
{
int choice, radius, length, width, height; //integers used to prevent user from using decimals, Boleen value declared
float SA;
choice = menu();
while (choice != 5)
{
if (choice == 1)
{
radius = getValue("Enter a radius: ",1,10);
SA = CalcSphere(radius);
cout << SA;
}
if (choice == 2)
{
radius = getValue("Enter a radius: ",1,7);
length = getValue("Enter a length: ",1,12);
SA = CalcCone(radius);
cout << SA;
}
if (choice == 3)
{
width = getValue("Enter a width: ",1,20);
length = getValue("Enter a length: ",1,20);
height = getValue("Enter a height: ",1,20);
SA = CalcPrism(radius);
cout << SA;
}
if (choice == 4)
{
length = getValue("Enter a length: ",1,15);
height = getValue("Enter a height: ",1,15);
cout << SA;
}
choice = menu();
}
}
//float calcSphere( int radius );