Advertisement
Guest User

TIWASON SA BALAY

a guest
Jul 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <math.h>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.  
  10. /*
  11. START MAIN MENU
  12. */
  13. mainmenu:
  14. char menu;
  15.  
  16. cout << "\t Main List Option\n\n";
  17. cout <<"\t [A] Perimeter\n";
  18. cout <<"\t [B] Area\n";
  19. cout <<"\t [C] Surface Area\n";
  20. cout <<"\t [D] Exit\n";
  21. cout <<"\t Enter Option: ";
  22. cin >> menu;
  23.  
  24. // START MENU SWITCH
  25. switch(menu){
  26. case 'a':
  27. char permenu;
  28. perimeter:
  29. system("CLS");
  30. cout << "\t Perimeter \n\n";
  31. cout << "\t Geometric Figure\n\n";
  32. cout << "1] Square\n";
  33. cout << "2] Rectangle\n";
  34. cout << "3] Back to Main List of Options\n";
  35. cout << "\t Enter Option: ";
  36.  
  37. // PERIMETER MENU
  38. permenu:
  39. cin >> permenu;
  40. switch (permenu){
  41. // SQUARE
  42. case '1':
  43. double side, total;
  44. system("CLS");
  45. cout << "\t Square \n";
  46. cout << "Enter measurement for one side of the square: ";
  47. cin >> side;
  48. cout << "inches\n";
  49. total = 4*side;
  50. cout << "The perimeter of a square with a side measurement \n" << "\t of " << side << "inches\n";
  51. cout << "\t is " << total <<"inches\n\n" ;
  52. cout << "Would you like to go back to Perimeter menu <Y/N>";
  53.  
  54. // prompt
  55. char prompt;
  56. promptsquare:
  57. cin >> prompt;
  58. switch (prompt){
  59. case 'y':
  60. goto perimeter;
  61. case 'Y':
  62. goto perimeter;
  63. case 'n':
  64. exit(0);
  65. case 'N':
  66. exit(0);
  67. default :
  68. cout << "Please enter only <Y/N>\n";
  69. goto promptsquare;
  70. break;
  71. }
  72. // RECTANGLE
  73. case'2':
  74. double base,length;
  75. system("CLS");
  76. cout << "\t Rectangle \n";
  77. cout << "Enter length and base: ";
  78. cin >> length >> base;
  79. double rectotal;
  80. rectotal = 2*(length + base);
  81. cout << "The area of the rectangle is: " << rectotal << "\n";
  82.  
  83. cout << "Would you like to go back to Perimeter menu <Y/N>";
  84. // prompt
  85. char promptrect;
  86. promptrect:
  87. cin >> promptrect;
  88. switch (promptrect){
  89. case 'y':
  90. goto perimeter;
  91. case 'Y':
  92. goto perimeter;
  93. case 'n':
  94. exit(0);
  95. case 'N':
  96. exit(0);
  97. default :
  98. cout << "Please enter only <Y/N>\n";
  99. goto promptrect;
  100. break;
  101. }
  102. // BACK TO MAIN MENU
  103. case'3':
  104. goto mainmenu;
  105.  
  106. default:
  107. cout << "Please enter numbers 1-3. \n";
  108. goto permenu;
  109. }
  110.  
  111. case 'b':
  112. char areamenu;
  113. area:
  114. system("CLS");
  115. cout << "\t Area \n\n";
  116. cout << "1] Triangle\n";
  117. cout << "2] Trapezoid\n";
  118. cout << "3] Circle\n";
  119. cout << "4] Back to Main List of Options\n";
  120. cout << "\t Enter Option: ";
  121.  
  122. // START AREA MENU
  123. cin >> areamenu;
  124. switch(areamenu){
  125. //Triangle
  126. case '1':
  127. double base,height,tritotal;
  128. system("CLS");
  129. cout << "\t Triangle \n";
  130. cout << "Enter base and height: ";
  131. cin >> base >> height;
  132. tritotal = base*height/2;
  133. cout << "The area of the triangle is: " << tritotal << "\n";
  134.  
  135. cout << "Would you like to go back to Area menu <Y/N>";
  136. // prompt
  137. char promptri;
  138. promptri:
  139. cin >> promptri;
  140. switch (promptri){
  141. case 'y':
  142. goto area;
  143. case 'Y':
  144. goto area;
  145. case 'n':
  146. exit(0);
  147. case 'N':
  148. exit(0);
  149. default :
  150. cout << "Please enter only <Y/N>\n";
  151. goto promptri;
  152. break;
  153. }
  154. case '2':
  155. double base1,base2,traptotal;
  156. system("CLS");
  157. cout << "\t Trapezoid \n";
  158. cout << "Enter base1, base2, and height: ";
  159. cin >> base1 >> base2 >> height;
  160. traptotal = (base1+base2)*height*1/2;
  161. cout << "The area of the trapezoid is: " << traptotal << "\n";
  162.  
  163. cout << "Would you like to go back to Area menu <Y/N>";
  164. // prompt
  165. char promptrap;
  166. promptrap:
  167. cin >> promptrap;
  168. switch (promptrap){
  169. case 'y':
  170. goto area;
  171. case 'Y':
  172. goto area;
  173. case 'n':
  174. exit(0);
  175. case 'N':
  176. exit(0);
  177. default :
  178. cout << "Please enter only <Y/N>\n";
  179. goto promptrap;
  180. break;
  181. }
  182. }
  183. }
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement