Hi guys sorry im really stucked trying to make a progrm that calculates areas of trianfgles rects and circles but i cant manage to figure out a way of making the main function to call the classes made for each figure.
What i have in mind is making like individual classes for each figure and let the user choose 1, 2, or 3 for Rect, Circ , or Triangle.
how can you help me. Thanks. im waiting :)
The thing is that i dont understand how to call like a class into the main function. Like asking the user which figure it needs to be calcĀ“d so depending of the choice, call Circle Class, TriangleĀ“s etc..
thanks sorry :(
#include <iostream>
#include <cmath>
usingnamespace std;
int main (){
double choice;
cout<< ("Please enter: ") << endl;
cout<< ("1) To calculate a Rectangle's Area.") << endl;
cout<< ("2) To calculate a Triangles's Area.") << endl;
cout<< ("3) To calculate a Circle's Area.") << endl;
cin>> choice;
}
double areas (){
//Rect
double w, l, h, ArRect;
cout << "Rectangle Area" << endl << ("Please enter the width, length and height.");
cin >> w >> l >> h;
ArRect = w * l * h;
cout << ("The Area of the Box is: ") << ArRect << endl;
system ("Pause");
return 0;
//Triangle
double l1, l2 ,l3, s, ArTri;
cout<< ("Please enter the values for the three sides.") << endl;
cin >> l1 >> l2 >> l3;
s = ((l1 + l2 + l3)/2);
ArTri = (sqrt(s*(s-l1) * (s -l2) *(s-l3)));
cout << ("The Triangle's Area is: ") << ArTri << endl;
system ("Pause");
return 0;
double ACir, R;
double Pi = 3.1416;
cout<< ("Please Enter the value of the Radius of the Circle.") << endl;
cin>> R;
ACir = (Pi * (pow(R,2)));
cout<< ("The Circle's Area is: ") << ACir << endl;
system ("Pause");
}