Advertisement
v4m4v4

AreaOfFigures

Sep 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. // AreaOfFigures.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <iomanip>
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     double area;
  13.     string geometry_figure = "square";
  14.     string geometry_figure = "rectangle";
  15.     string geometry_figure = "circle";
  16.     string geometry_figure = "triangle";
  17.     cin >> geometry_figure;
  18.  
  19.     if (geometry_figure == "square")
  20.     {
  21.         double side_a;
  22.         cin >> side_a;
  23.         area = side_a * side_a;
  24.     }
  25.     else if (geometry_figure == "rectangle")
  26.     {
  27.         double side_b, side_c;
  28.         cin >> side_b >> side_c;
  29.         area = side_b * side_c;
  30.     }
  31.     else if (geometry_figure == "circle")
  32.     {
  33.         double radius;
  34.         double pi = 3.14159265359;
  35.         cin >> radius;
  36.         area = (pi * radius * radius);
  37.     }
  38.     else  if (geometry_figure == "triangle")
  39.     {
  40.         double width, hight;
  41.         cin >> width, hight;
  42.         area = (width * hight) / 2;
  43.     }
  44.  
  45.     cout << fixed << setprecision(3) << area << endl;
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement