Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. // lab7.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //Michael MacRonald
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8. int choice;
  9. double width;
  10. double length;
  11. double radius;
  12. double A;
  13. double B;
  14. double area;
  15. const double pi = 3.1415;
  16. cout << "Object area calculator menu\n";
  17. cout << "1. Square\n";
  18. cout << "2. Circle\n";
  19. cout << "3. Right Triangle\n";
  20. cout << "4. Quit\n";
  21. cin >> choice;
  22.  
  23. if (choice == 1)
  24. {
  25. cout << "Enter Width\n";
  26. cin >> width;
  27. cout << "Enter length\n";
  28. cin >> length;
  29. area = width * length;
  30. cout << "Area of the square =" << area;
  31.  
  32. }
  33. else if (choice == 2)
  34. {
  35. cout << "Enter radius of circle\n";
  36. cin >> radius;
  37. area = pi * radius * radius;
  38. cout << "Area of the circle =" << area;
  39. }
  40. else if (choice == 3)
  41. {
  42. cout << "Enter Length of leg A\n";
  43. cin >> A;
  44. cout << "Enter Lenth of leg B\n";
  45. cin >> B;
  46. area = (A * B) / 2;
  47. cout << "The area of the right triangle =\n" << area;
  48. }
  49. else if (choice == 4)
  50. {
  51. cout << "End of program";
  52. }
  53. else
  54. {
  55. cout << "The valid choices are 1 through 5\n";
  56. cout << "Please rerun the program and select one of those.";
  57. }
  58. return 0;
  59. }
  60. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  61. // Debug program: F5 or Debug > Start Debugging menu
  62.  
  63. // Tips for Getting Started:
  64. // 1. Use the Solution Explorer window to add/manage files
  65. // 2. Use the Team Explorer window to connect to source control
  66. // 3. Use the Output window to see build output and other messages
  67. // 4. Use the Error List window to view errors
  68. // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  69. // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement