Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <110ct.h>
- #include <string>
- using namespace std;
- void calculatecone (double a, double v, double radius);
- void calculatecircle (double a, double radius);
- void calculatecylinder (double a, double v, double radius);
- const double pi = 3.1415;
- double radius;
- double height;
- char shape, areavolume;
- ColourController cl;
- int main ()
- {
- cout << "3D Shape Area & Volume Calculator \n\n";
- cout << "Shapes Key: \n";
- cout << "Cone \n";
- cout << "Cylinder \n";
- cout << "Circle \n\n";
- cout << "\nPlease specify the shape, which can be either a circle, cone or cylinder: \n";
- cl.setForeground (Aqua);
- cin >> shape;
- cout << endl;
- cl.setForeground (Blue);
- cout << "\nPlease specify whether you wish to calculate the area or the volume of the shape: \n";
- cl.setForeground (Aqua);
- cin >> areavolume;
- cout << endl;
- cl.setForeground (Blue);
- cout << "\nPlease specify the radius of the shape: \n";
- cl.setForeground (Aqua);
- cin >> radius;
- cout << endl;
- cl.setForeground (Blue);
- cout << "\nPlease specify the height of the shape: \n";
- cl.setForeground (Aqua);
- cin >> height;
- cout << endl;
- if (shape == "circle" || shape == "Circle")
- {
- if (areavolume == 'a' || areavolume =='A')
- {
- void calculatecircle();
- }
- if (areavolume == 'v' || areavolume == 'V')
- {
- cout << "\nSorry it is not possible to work out the volume of a circle, as it is a 2D shape. \n";
- }
- }
- else if (shape == 'c' || shape == 'c')
- {
- void calculatecone();
- }
- qin.get();
- return 0;
- }
- void calculatecircle (double a, double radius)
- {
- a = pi*radius*radius;
- cout << "The area of your circle is: " << a << endl;
- }
- void calculatecone (double a, double v)
- {
- if (areavolume == 'a' || areavolume == 'A')
- {
- a = pi*radius*height + pi*radius*radius;
- cout << "The area of your cone is: " << a << endl;
- }
- else if (areavolume == 'v' || areavolume == 'V')
- {
- v = pi*radius*radius*height/3;
- cout << "\nThe volume of your cone is: " << v << endl;
- }
- }
- void calculatecylinder (double a, double v)
- {
- if (areavolume == 'a' || areavolume == 'A')
- {
- a = 2*pi*radius*radius + 2*pi*radius*height;
- cout << "The area of your cylinder is: " << a << endl;
- }
- if (areavolume == 'v' || areavolume == 'V')
- {
- v = pi*radius*radius*height;
- cout << "\nThe volume of your cylinder is: " << v << endl;
- }
- }
Add Comment
Please, Sign In to add comment