Hi
i did the simple part of my project and got it to run but now i have to add in prototypes. can someone please help
bool validRadius(double);
bool validLengthAndWidth(double, double);
bool validBaseAnd Height(double, double);
I will also create functions which will calculate the area of the various geometric objects. These functions will be called from within each of the valid data cases in your switch-case selection construct. In each of the different cases, validate the data first and call the function if the data is in fact valid. If called, each of the functions will then calculate their respective areas and then return the value of its calculation to be printed within the case ( or write another function to do the printing.).
Use the following prototypes:
double areaCircle(double);
double areaRectangle(double, double);
double areaTriangle( double, double);
my programs
#include <iostream>
#include <iomanip>
#include <cmath> // needed for pow function
using namespace std;
int main()
{
int choice; //menu choice
double PI= 3.14159;
double area, radius, base, num1, length, height, width;
while (choice != 4)
{
cout << "\t\tGeometry Calculator Menu\n\n";
cout << "1. Calculate the Area of a Circle\n";
cout << "2. Calculate the Area of a Rectangle\n";
cout << "3. Calculate the Area of a Triangle\n";
cout << "4. Quit the Program\n\n";
cout << "Enter your choice (1-4): ";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter the radius: ";
cin >> radius;
area = 3.14159 * pow(radius, 2.0);
cout << "Area = " << area << "\tsquare units" << endl;
break;
case 2:
do
{
cout << "Enter length: ";
cin >> length;
while (length < 0 )
{
cout << "Please enter a positive length value: " << endl;
cin >> length;
}
cout << "Enter width: ";
cin >> width;
while (width < 0 )
{
cout << "Please enter a positive width value: " << endl;
cin >> width;
}
}
while ( length < 0 || width < 0 );
area = length * width;
cout << "Area of rectangle is: " << area << endl;
break;
case 3:
do
{
cout << "Enter base: ";
cin >> base;
while (base < 0 )
{
cout << "Please enter a positive base value: " << endl;
cin >> base;
}
cout << "Enter height: ";
cin >> height;
while (width < 0 )
{
cout << "Please enter a positive height value: " << endl;
cin >> height;
}
}
while ( height < 0 || base < 0 );
area = base * height * .5;
cout << "Area of triangle is: " << area << endl;
break;
case 4:
void exit (int exitcode);
break;
default:
cout << "**Error: Menu option must be 1, 2, 3 or 4." << endl;
cout << "Please try again." << endl;
break;
}
}
system("pause");
return 0;
}