Hey! I just started learning C++ last month, so I am not that good yet.
I am trying to write functions to compute the total surface area, lateral surface area, and volume of a right-circular cylinder. So I wrote the code, and it makes perfect sense to me. When I compiled it the first time I had 17 errors. I went through and fixed them, however I continue to get 3 errors. They are the same error for 3 lines in a row; error C2062: Type double unexpected. I thought that perhaps I had written "double" somewhere I didn't need, but that doesn't seem to be it. I have spent several hours trying to find the problem to no avail.
If you could help me without telling me exactly what to do, that would greatly appreciated!

/*function.cpp determines the total surface area, lateral surface area, and volume using a 
*calculation function named tsurfaceFUNCTION(), lsurfaceFUNCTION(), and volumeFUNCTION() repectively.
*Author: Cole Davidson
*Date: October 20, 2009
*Input: radius, height
*Output: total surface area, lateral surface area, volume
*/

#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
	cout<<"This program calculates the total surface area,\n";
	cout<<"lateral surface area and volume of a cylinder.\n";

	const double PI = 3.14159;
	
	cout<<"\nEnter the radius: ";
	double radius;
	cin>>radius;

	cout<<"\nEnter the height: ";
	double height;
	cin>>height;

	double tsurface = double tsurfaceFUNCTION (double radius, double height, const double PI);
	double lsurface = double lsurfaceFUNCTION (double radius, double height, const double PI);
	double volume = double volumeFUNCTION (double radius, double height, const double PI);

	cout<<"The total surface area of the cylinder is "<<tsurface<<", while the lateral surface area is "<<lsurface<<". The volume of the cylinder is "<<volume<<".";
}

/*The function tsurfaceFUNCTION calculates the total surface area of a cylinder.
*/
double tsurfaceFUNCTION (double radius, double height, const double PI)
{
	return 2 * PI * radius * (radius + height);
}

/*The function lsurfaceFUNCTION calculates the lateral surface area of a cylinder.
*/
double lsurfaceFUNCTION (double radius, double height, const double PI)
{
	return 2 * PI * radius * height;
}

/*The function volumeFUNCTION calculates the volume of the cylinder.
*/
double volumeFUNCTION (double radius, double height, const double PI)
{
	return PI * pow(radius, 2.0) * height;
}

1>------ Build started: Project: assignment function, Configuration: Debug Win32 ------
1>Compiling...
1>function.cpp
1>c:\users\cole\documents\visual studio 2008\projects\assignment function\assignment function\function.cpp(28) : error C2062: type 'double' unexpected
1>c:\users\cole\documents\visual studio 2008\projects\assignment function\assignment function\function.cpp(29) : error C2062: type 'double' unexpected
1>c:\users\cole\documents\visual studio 2008\projects\assignment function\assignment function\function.cpp(30) : error C2062: type 'double' unexpected
1>Build log was saved at "file://c:\Users\Cole\Documents\Visual Studio 2008\Projects\assignment function\assignment function\Debug\BuildLog.htm"
1>assignment function - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Your syntax is invalid. You're using the syntax for declaring a function, when you should be using the syntax for calling a function:

double tsurface = tsurfaceFUNCTION(radius, height, double PI);

Note that you'll need to declare tsurfaceFunction before you use it, above the main function.

Uh, I meant

double tsurface = tsurfaceFUNCTION(radius, height, PI);

of course.

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.