Advertisement
endreweast

Untitled

Nov 2nd, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. // Атрибут first – ціле додатнє число, калорійність100г продукту; атрибут second – дробове додатнє число, маса продукту в кілограмах. Реалізувати метод power() - обчислення загальної калорійності продукту. //
  2. #include <math.h>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. class MyClass
  8. {
  9.     private:
  10.         int first;
  11.         float second;
  12.         float x;
  13.     public:
  14.         void init()
  15.         {
  16.             first=5000;
  17.         }
  18.         void read()
  19.         {
  20.             cout<<"Write second"<<endl;
  21.             cin>>second;
  22.         }
  23.         float power()
  24.         {
  25.             x=(second*first)/10;
  26.         }
  27.         float display()
  28.         {
  29.             return x;
  30.         }
  31. };
  32.  
  33.  
  34. int main()
  35. {
  36.     MyClass obj;
  37.     obj.init();
  38.     obj.read();
  39.     obj.power();
  40.     cout<<"Result x="<<obj.display()<<endl;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement