anyone free to chat c++?

Goosemaster

Lifer
Apr 10, 2001
48,775
3
81
Still having problems:(


basically I got my functions going and such, but just need help with storing values:(
 

Goosemaster

Lifer
Apr 10, 2001
48,775
3
81
check out this bute:

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


//function prototypes
double area_of_triangle ( double triangle_base, double triangle_height);
double area_of_circle ( double circle_radius);
double area_of_rectangle ( double rectangle_base, double rectangle_height);
double area_of_square ( double square_base );

/*Programmer-defined FUNCTIONS------------------------------------------------*/


//this function finds the area of triangle given the base and the height

double area_of_triangle ( double triangle_base, double triangle_height)
{
return (triangle_base*(.5 * triangle_height));
}



//this function finds the area of circle given the radius

double area_of_circle ( double circle_radius)
{
return (3.14*circle_radius*circle_radius);
}

//this function finds the area of a rectangle

double area_of_rectangle ( double rectangle_base, double rectangle_height)
{
return (rectangle_base*rectangle_height);
}


//this function finds the area of a square

double area_of_square ( double square_base )
{
return (square_base*square_base);
}


/*Programmer-defined FUNCTIONS------------------------------------------------*/

int main()
{

//declared objects
double triangle_base;
double triangle_height;
double circle_radius;
double rectangle_base;
double rectangle_height;
double square_base;
char m;
char n;
double p = 0;





//program introduction. Asks for confirmation to continue
cout << "This program allows you to find the total area of onsite plots" << endl;
cout << "\n\nWould you like to continue?" << endl;
cout << "TYPE YES OR NO TO CONTINUE" << endl;
cin >> m;

//decides whether they typed yes or no by simply checking the first letter
switch( m ) {
case 'y':
case 'Y':
cout << "\n\n\nGreat, let's get started!" << endl;
//if yes, the temp. program begins asking user for which task to proceed with


do

{
//menu system for conversion modules
cout << "\n\nPlease select an action " << endl;
cout << "\n\na)Add a Triagular Plot \nb)Add a Circular Plot \nc)Add a Rectangular Plot \nd)Add a Square Plot \ne)I'm done" << endl;
cin >> n;

//starts the appropriate module for the choice that the user provides
switch (n)
{
//first case executes the Triangular Plot module
case 'a':
case 'A':

cout << "\n\nYou chose to add a Triangular plot \n\nLet's get started!" << endl;
cout << "\n\nWhat are enter the dimensions this plot?" << endl;
cout << "\n\nHeight: " << endl;
cin >> triangle_height;
cout << "\n\nLength of Base: " << endl;
cin >> triangle_base;
cout << "That equals and area of " << area_of_triangle ( triangle_base, triangle_height) << " square feet" << endl;

p = (p + area_of_triangle ( triangle_base, triangle_height));

break;

//second case executes the Circular Plot Module
case 'b':
case 'B':

cout << "\n\nYou chose to add a Circular plot \n\nLet's get started!" << endl;
cout << "\n\nWhat are enter the dimensions this plot?" << endl;
cout << "\n\nRadius: " << endl;
cin >> circle_radius;
cout << "That equals and area of "<< area_of_circle ( circle_radius) << " square feet" << endl;

p= (p + area_of_circle ( circle_radius));
break;

//Third case executes the Rectangular Plot Module
case 'c':
case 'C':

cout << "\n\nYou chose to add a Rectangular plot \n\nLet's get started!" << endl;
cout << "\n\nWhat are enter the dimensions this plot?" << endl;
cout << "\n\nHeight: " << endl;
cin >> rectangle_height;
cout << "\n\nLength of Base: " << endl;
cin >> rectangle_base;
cout << "That equals and area of "<< area_of_rectangle ( rectangle_base, rectangle_height) << " square feet" << endl;

p= (p + area_of_rectangle ( rectangle_base, rectangle_height));
break;

//Fourth case executes the Square Plot Module
case 'd':
case 'D':
cout << "\n\nYou chose to add a Square plot \n\nLet's get started!" << endl;
cout << "\n\nWhat are enter the dimensions this plot?" << endl;
cout << "\n\nLength of one of the sides: " << endl;
cin >> square_base;
cout << "That equals and area of "<< area_of_square ( square_base ) << " square feet" << endl;

p= (p + area_of_square ( square_base ));
break;



}

}

//when the user hooses option e, the while loop does not apply and the program ends
while ( n!= 'e');

cout << "The total area of plots entered was " << p << endl;
cout << "\n\n\nThank you." << endl;


//if not, the program identifies their answer as a no and the program ends
break;
case 'n':
case 'N':
cout << " too bad." << endl;
break;
default:
cout << "too bad" << endl;
break;

}



//fin
system ("PAUSE");

}