Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Атрибут first – ціле додатнє число, калорійність100г продукту; атрибут second – дробове додатнє число, маса продукту в кілограмах. Реалізувати метод power() - обчислення загальної калорійності продукту. //
- #include <math.h>
- #include <iostream>
- using namespace std;
- class MyClass
- {
- private:
- int first;
- float second;
- float x;
- public:
- void init()
- {
- first=5000;
- }
- void read()
- {
- cout<<"Write second"<<endl;
- cin>>second;
- }
- float power()
- {
- x=(second*first)/10;
- }
- float display()
- {
- return x;
- }
- };
- int main()
- {
- MyClass obj;
- obj.init();
- obj.read();
- obj.power();
- cout<<"Result x="<<obj.display()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement