Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 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. cout << "What is the radius of the circle?\n";
  17. cin >> radius;
  18. do
  19. {
  20. area = pow((pi * radius), 2);
  21. cout << "The area of that circle is " << area << " square units!\n";
  22. } while (radius >= 0);
  23. }
  24. else if (num == 2)
  25. {
  26. cout << "Please enter the length of the rectange:\n";
  27. cin >> length;
  28. cout << "Now please enter the width of the rectangle:\n";
  29. cin >> width;
  30. do
  31. {
  32. area = length * width;
  33. cout << "The area of your rectangle is " << area << " square units!\n";
  34. } while (length >= 0 && width >= 0);
  35. }
  36. else if (num == 3)
  37. {
  38. cout << "Please enter the base of the triangle:\n";
  39. cin >> base;
  40. cout << "Please enter the height for your triangle:\n";
  41. cin >> height;
  42. do
  43. {
  44. area = base * (.5 * height);
  45. cout << "The area of that triangle is " << area << " square units!\n";
  46. } while (base >= 0 && height >= 0);
  47. }
  48. else if (num == 4)
  49. {
  50. return 0;
  51. }
  52.  
  53. system("pause");
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement