Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
1.3 kB
2
Indexable
Never
#include <iostream>
#include <cmath>

using namespace std;

class Prisma {
private:
    double latura_bazei;
    double inaltime;

    double permiterul_bazei() {
        return 6 * this->latura_bazei;
    }

    double aria_bazei() {
        return 3 * pow(latura_bazei, 2) * sqrt(3) / 2;
    }

public:
    void set_dimensiuni(double latura_bazei, double inaltime) {
        this->latura_bazei = latura_bazei;
        this->inaltime = inaltime;
    }

    double aria_laterala() {
        return this->permiterul_bazei() * inaltime;
    }

    double aria_totala() {
        return aria_laterala() + (2 * aria_bazei());
    }

    double volum() {
        return aria_bazei() * inaltime;
    }
};

int main() {
    double latura_baza, inaltime;
    char option;

    do {
        cout << "Introduceti valorile..." << endl;
        cout << "Latura bazei: " << endl;
        cin >> latura_baza;
        cout << "Inaltimea: " << endl;
        cin >> inaltime;

        Prisma p;
        p.set_dimensiuni(latura_baza, inaltime);

        cout << "Aria laterala: " << p.aria_laterala() << endl;
        cout << "Aria totala: " << p.aria_totala() << endl;
        cout << "Volum: " << p.volum() << endl;

        cout << "Doriti sa reintroduceti alte valori? Y/N" << endl;
        cin >> option;

    } while (option != 'N');

    return 0;
}
Leave a Comment