Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string figure;
- cin >> figure;
- double area = 0;
- if (figure == "square") {
- double side;
- cin >> side;
- area = side * side;
- }
- else if (figure == "rectangle") {
- double length, width;
- cin >> length >> width;
- area = length * width;
- }
- else if (figure == "circle") {
- double radius;
- cin >> radius;
- area = 3.14159265359 * radius * radius;
- }
- else if (figure == "triangle") {
- double base, height;
- cin >> base >> height;
- area = base * height / 2;
- }
- cout.setf(ios::fixed);
- cout.precision(3);
- cout << area << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement