Hey guys im making a Calculator that returns Rectangles, Triangles or Circles Area. the thing is that i already set up everything but I need to do something to let the user coose between which Figure it needs to calc. How can would a class could be used for each figure?
HereĀ“s the code im sorry for the bothering im just a noob lol.
#include <iostream>
#include <cmath>
usingnamespace std;
int main (){
int choice = 0;
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;
//Rectangle
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");
}
//Circle
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: ") << endl;
system ("Pause");
return 0;
}