too few arguments in function call error
Doing an assignment to calculate the area and volume of different shapes.
Stuck is an understatement. Get an error claiming 'showMenu': function
does not take 0 arguments & a also a too few arguments in function call
error. Any pointers on how to fix this?
#include <iostream>
#include <iomanip>
using namespace std;
//Functions
void showMenu(int &);
double area (double, double);
double area (double);
double volume (double, double, double);
double volume (double);
const double PI = 3.14;
int main()
{
int choice;
double area, volume, length, width, radius, height;
const double PI = 3.14;
do
{
showMenu();
cin >> choice;
if (choice < 1 || choice > 5 )
{
cout << "Please select a valid choice of 1-5: " << endl;
cin >> choice;
}
else if (choice == 1)
{
double tarea(area);
cout << "Enter the length: ";
cin >> length;
cout << "Enter the width: ";
cin >> width;
cout << "The area of the rectangle is: " << tarea << endl;
}
else if (choice == 2)
{
double tarea(area);
cout << "Enter the radius: ";
cin >> radius;
cout << "The area of the circle is: " << tarea << endl;
}
else if (choice == 3)
{
double tvolume (volume);
cout << "Enter the length: ";
cin >> length;
cout << "Enter the width: ";
cin >> width;
cout << "Enter the height: ";
cin >> height;
cout << "The volume for a box is: " << tvolume << endl;
}
else if (choice == 4)
{
double tvolume (volume);
cout << "Enter the radius: ";
cin >> radius;
cout << "The volume of a sphere is: " << endl;
}
}
while (choice != 5);
return 0;
}
void ShowMenu(int &choice)
{
cout << "1. Calculate the area of a rectangle";
cout << "2. Calculate the area of a circle";
cout << "3. Calculate the volume for a box";
cout << "4. Calculate the volume of a sphere";
cout << "5. Quit";
}
double area (double length, double width)
{
double tarea = length * width;
return tarea;
}
double area (double radius)
{
double tarea = PI * (radius * radius);
return tarea;
}
double volume (double length, double width, double height)
{
double tvolume = length * width * height;
return tvolume;
}
double volume (double radius)
{
double tvolume = (4/3) * PI * (radius * radius * radius);
return tvolume;
}
No comments:
Post a Comment