Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Создать класс, описывающий круг.Определить площадь круга.Определить площадь кольца, образованного двумя концентрическими кругами.
- Создать класс - наследник, описывающий конус.Определить ребро куба, имеющего объем, совпадающий с объемом этого конуса.*/
- #include <iostream>
- #include <cmath>
- using namespace std;
- class circle
- {
- public:
- float rad;
- circle(float value)
- {
- rad = value;
- }
- float circlear()
- {
- float area;
- area = 3.14 * rad * rad;
- return area;
- }
- };
- class cone : public circle {
- public:
- float height;
- cone(float value, float value1) : circle(value)
- {
- height = value1;
- }
- float conearea() {
- float circar = circlear();
- float conar = 0.334 * circar * height;
- return conar;
- }
- };
- void main()
- {
- while (1) {
- int number;
- cout << "1. Find circle area" << endl;
- cout << "2. Find ring area" << endl;
- cout << "3. Find edge of the cube" << endl;
- cout << "Choose number: ";
- cin >> number;
- switch (number) {
- case 1: {
- float radius111, area;
- cout << "Enter radius: " << endl;
- cin >> radius111;
- circle cir3(radius111);
- area = cir3.circlear();
- cout << "Circle area: " << area << endl;
- break;
- }
- case 2: {
- float radius1, radius2, ringarea;
- cout << "Enter radius1: ";
- cin >> radius1;
- cout << endl << "Enter radius2: ";
- cin >> radius2;
- circle cir1(radius1);
- circle cir2(radius2);
- ringarea = cir1.circlear() - cir2.circlear();
- cout << "Ring area: " << abs(ringarea) << endl;
- break;
- }
- case 3: {
- float radius11, height1, sqar;
- cout << "Enter radius: ";
- cin >> radius11;
- cout << endl << "Enter height: ";
- cin >> height1;
- cone cil1(radius11, height1);
- sqar = cbrt(cil1.conearea());
- cout << "Edge of the cube: " << sqar << endl;
- break;
- }
- default:
- cout << "Wrong number";
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement