Advertisement
Guest User

WRONG

a guest
Jul 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cmath>
  4. #include<math.h>
  5.  
  6. #define PI 3.14
  7.  
  8. using namespace std;
  9.  
  10. void aos(){
  11. double side,aosquare;
  12. cout << "Input side: " << endl;
  13. cin >> side;
  14. if (side < 0){
  15. cout <<"ERROR! Please input a positive number!" << endl;
  16. aos();
  17. }
  18. aosquare = pow(side,2);
  19. cout << "Area of square is " << aosquare << "." << endl;
  20. }
  21.  
  22. void por(){
  23. double l, w;
  24. cout << "Input length and width" << endl;
  25. cin >> l >> w;
  26. if (l < 0 && w < 0){
  27. cout <<"ERROR! Please input a positive number!" << endl;
  28. por();
  29. }
  30. double prectangle;
  31. prectangle = l * w;
  32. cout << "Perimeter of Rectangle: " << prectangle << endl;
  33. }
  34.  
  35. void voc(){
  36. cout <<"Input r and h: " << endl;
  37. double r, h, vcylinder;
  38. cin >> r >> h;
  39. if(r < 0 && h < 0)
  40. {
  41. cout <<"ERROR! Please input a positive number!" << endl;
  42. voc();
  43. }
  44. vcylinder = (PI) * pow(r,2) * h;
  45. cout << "The volume of the cylinder is " << vcylinder << endl;
  46. }
  47.  
  48. int main(){
  49. cout << "Developed by: Francis Gabriento" << endl;
  50. cout << "Station No.: 34" << endl;
  51. cout <<"MENU" << endl;
  52. double = choice;
  53. cout << "\t [1] Area of Square " << endl;
  54. cout <<"\t [2] Perimeter of a Rectangle" << endl;
  55. cout << "\t[3] Volume of a Cylinder " << endl;
  56. cout <<"Key in your choice: ";
  57. cin >> choice;
  58. switch(choice){
  59. case "1":
  60. aos();
  61. break;
  62. case "2":
  63. por();
  64. break;
  65. case "3":
  66. voc();
  67. break;
  68. default:
  69. cout << "You chose an Unknown Number!" << endl;
  70. cout <<"Please choose between [1], [2], and [3]" << endl << endl << endl;
  71. main();
  72. break;
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement