Guest User

Untitled

a guest
Jun 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 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, double height);
  8. void calculatecircle (double a, double radius, double height);
  9. void calculatecylinder (double a, double v, double radius, double heigh);
  10.  
  11. const double pi = 3.1415;
  12.  
  13. double radius;
  14. double height;
  15.  
  16. string 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 == "area" || areavolume =="Area")
  51. {
  52. void calculatecircle(double a, double radius, double height);
  53. }
  54. if (areavolume == "volume" || areavolume == "Volume")
  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 == "cone" || shape == "Cone")
  61. {
  62. void calculatecone(double a, double v, double radius, double height);
  63. }
  64.  
  65. else if (shape == "cylinder" || shape == "Cylinder")
  66. {
  67. void calculatecylinder (double a, double v, double radius, double height);
  68. }
  69.  
  70. qin.get();
  71. return 0;
  72. }
  73.  
  74. void calculatecircle (double a, double radius, double height)
  75. {
  76. a = pi*radius*radius;
  77. cout << "The area of your circle is: " << a << endl;
  78. }
  79.  
  80. void calculatecone (double a, double v, double radius, double height)
  81. {
  82. if (areavolume == "area" || areavolume == "Area")
  83. {
  84. a = pi*radius*height + pi*radius*radius;
  85. cout << "The area of your cone is: " << a << endl;
  86. }
  87. else if (areavolume == "volume" || areavolume == "Volume")
  88. {
  89. v = pi*radius*radius*height/3;
  90. cout << "\nThe volume of your cone is: " << v << endl;
  91. }
  92. }
  93.  
  94. void calculatecylinder (double a, double v, double radius, double height)
  95. {
  96. if (areavolume == "area" || areavolume == "Area")
  97. {
  98. a = 2*pi*radius*radius + 2*pi*radius*height;
  99. cout << "The area of your cylinder is: " << a << endl;
  100. }
  101. if (areavolume == "volume" || areavolume == "Volume")
  102. {
  103. v = pi*radius*radius*height;
  104. cout << "\nThe volume of your cylinder is: " << v << endl;
  105. }
  106. }
Add Comment
Please, Sign In to add comment