Guest User

Untitled

a guest
Jun 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <110ct.h>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void calculatecone (double a, double v, double radius);
  8. void calculatecircle (double a, double radius);
  9. void calculatecylinder (double a, double v, double radius);
  10.  
  11. const double pi = 3.1415;
  12.  
  13. double radius;
  14. double height;
  15.  
  16. char shape, areavolume;
  17.  
  18. ColourController cl;
  19.  
  20. int main ()
  21. {
  22. cout << "3D Shape Area & Volume Calculator \n\n";
  23. cout << "Shapes Key: \n";
  24. cout << "Cone \n";
  25. cout << "Cylinder \n";
  26. cout << "Circle \n\n";
  27.  
  28. cout << "\nPlease specify the shape, which can be either a circle, cone or cylinder: \n";
  29. cl.setForeground (Aqua);
  30. cin >> shape;
  31. cout << endl;
  32. cl.setForeground (Blue);
  33. cout << "\nPlease specify whether you wish to calculate the area or the volume of the shape: \n";
  34. cl.setForeground (Aqua);
  35. cin >> areavolume;
  36. cout << endl;
  37. cl.setForeground (Blue);
  38. cout << "\nPlease specify the radius of the shape: \n";
  39. cl.setForeground (Aqua);
  40. cin >> radius;
  41. cout << endl;
  42. cl.setForeground (Blue);
  43. cout << "\nPlease specify the height of the shape: \n";
  44. cl.setForeground (Aqua);
  45. cin >> height;
  46. cout << endl;
  47.  
  48. if (shape == "circle" || shape == "Circle")
  49. {
  50. if (areavolume == 'a' || areavolume =='A')
  51. {
  52. void calculatecircle();
  53. }
  54. if (areavolume == 'v' || areavolume == 'V')
  55. {
  56. cout << "\nSorry it is not possible to work out the volume of a circle, as it is a 2D shape. \n";
  57. }
  58. }
  59.  
  60. else if (shape == 'c' || shape == 'c')
  61. {
  62. void calculatecone();
  63. }
  64.  
  65. qin.get();
  66. return 0;
  67. }
  68.  
  69. void calculatecircle (double a, double radius)
  70. {
  71. a = pi*radius*radius;
  72. cout << "The area of your circle is: " << a << endl;
  73. }
  74.  
  75. void calculatecone (double a, double v)
  76. {
  77. if (areavolume == 'a' || areavolume == 'A')
  78. {
  79. a = pi*radius*height + pi*radius*radius;
  80. cout << "The area of your cone is: " << a << endl;
  81. }
  82. else if (areavolume == 'v' || areavolume == 'V')
  83. {
  84. v = pi*radius*radius*height/3;
  85. cout << "\nThe volume of your cone is: " << v << endl;
  86. }
  87. }
  88.  
  89. void calculatecylinder (double a, double v)
  90. {
  91. if (areavolume == 'a' || areavolume == 'A')
  92. {
  93. a = 2*pi*radius*radius + 2*pi*radius*height;
  94. cout << "The area of your cylinder is: " << a << endl;
  95. }
  96. if (areavolume == 'v' || areavolume == 'V')
  97. {
  98. v = pi*radius*radius*height;
  99. cout << "\nThe volume of your cylinder is: " << v << endl;
  100. }
  101. }
Add Comment
Please, Sign In to add comment