Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Круг Problem 2 (0 / 0)
- Да се дефинира класа Krug, во која се чуваат информации за:
- радиус float
- бројот π const float.
- Во класата да се реализираат:
- default конструктор и конструктор со аргументи
- метод за пресметување плоштина
- метод за пресметување периметар
- метод кој кажува дали плоштината и периметарот на даден круг се еднакви
- */
- #include <iostream>
- using namespace std;
- class Krug {
- private:
- float radius;
- float pi = 3.14;
- public:
- Krug(){}
- Krug(float x, float y){
- radius = x;
- pi = y;
- }
- //Set Metodi
- void set_Radius(float r){
- radius = r;
- }
- void set_Pi(const float paj){
- pi = paj;
- }
- //Get Metodi
- float getRadius(){
- return radius;
- }
- const float getPi(){
- return pi;
- }
- //Presmetuvanje plostina
- float plostina(Krug a){
- a.pi = a.getPi();
- a.radius = a.getRadius();
- float area = a.pi * (a.radius * a.radius);
- return area;
- }
- //Presmetuvanje perimetar
- float perimetar(Krug a){
- a.pi = a.getPi();
- a.radius = a.getRadius();
- float circumference = 2* a.pi * a.radius;
- return circumference;
- }
- //Proverka dali se ednakvi plostinata i perimetarot
- int ednakvi(Krug x){
- float a,b;
- a = x.plostina(x);
- b = x.perimetar(x);
- if(a == b)
- return 1;
- else
- return 0;
- }
- };
- int main() {
- float r;
- const float pi = 3.14;
- cin >> r;
- //instanciraj objekt od klasata Krug cij radius e vrednosta procitana od tastatura
- Krug k(r,pi);
- cout << k.perimetar(k) << endl;
- cout << k.plostina(k) << endl;
- cout << k.ednakvi(k) <<endl;
- //instanciraj objekt od klasata Krug cij radius ne e definiran
- return 0;
- }
Add Comment
Please, Sign In to add comment