Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- double num, cir, rec, tri, pi, area, radius, length, width, base, height;
- pi = 3.14159;
- cout << "Would you like to find the area of a \n(1)Circle \n(2)Rectangle \n(3)Triangle?\n(4)Quit?\n";
- cin >> num;
- if (num == 1)
- {
- cout << "What is the radius of the circle?\n";
- cin >> radius;
- do
- {
- area = pow((pi * radius), 2);
- cout << "The area of that circle is " << area << " square units!\n";
- } while (radius >= 0);
- }
- else if (num == 2)
- {
- cout << "Please enter the length of the rectange:\n";
- cin >> length;
- cout << "Now please enter the width of the rectangle:\n";
- cin >> width;
- do
- {
- area = length * width;
- cout << "The area of your rectangle is " << area << " square units!\n";
- } while (length >= 0 && width >= 0);
- }
- else if (num == 3)
- {
- cout << "Please enter the base of the triangle:\n";
- cin >> base;
- cout << "Please enter the height for your triangle:\n";
- cin >> height;
- do
- {
- area = base * (.5 * height);
- cout << "The area of that triangle is " << area << " square units!\n";
- } while (base >= 0 && height >= 0);
- }
- else if (num == 4)
- {
- return 0;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement