Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. double num, cir, rec, tri, pi, area, radius, length, width, base, height;
  11. pi = 3.14159;
  12. cout << "Would you like to find the area of a \n(1)Circle \n(2)Rectangle \n(3)Triangle?\n(4)Quit?\n";
  13. cin >> num;
  14. if (num == 1)
  15. {
  16. do
  17. {
  18. cout << "What is the radius of the circle?\n";
  19. cin >> radius;
  20. area = pow((pi * radius), 2);
  21. } while (radius <= 0);
  22. cout << "The area of that circle is " << area << " square units!\n";
  23. }
  24. else if (num == 2)
  25. {
  26.  
  27. do
  28. {
  29. cout << "Please enter the length of the rectange:\n";
  30. cin >> length;
  31. cout << "Now please enter the width of the rectangle:\n";
  32. cin >> width;
  33. area = length * width;
  34. } while (length <= 0 && width <= 0);
  35. cout << "The area of your rectangle is " << area << " square units!\n";
  36. }
  37. else if (num == 3)
  38. {
  39. do
  40. {
  41. cout << "Please enter the base of the triangle:\n";
  42. cin >> base;
  43. cout << "Please enter the height for your triangle:\n";
  44. cin >> height;
  45. area = base * (.5 * height);
  46. } while (base <= 0 && height <= 0);
  47. cout << "The area of that triangle is " << area << " square units!\n";
  48. }
  49. else if (num == 4)
  50. {
  51. return 0;
  52. }
  53.  
  54. system("pause");
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement