Skip to content
Snippets Groups Projects
Commit e793b42d authored by Rudi Buss's avatar Rudi Buss
Browse files

Update Solution Exercise 2 - Animals.cpp

parent bc435586
No related branches found
No related tags found
No related merge requests found
......@@ -2,39 +2,37 @@
using namespace std;
class Animal
{
private:
float Revenue;
float Weight;
float DailyPrice;
public:
void Request_data() //Declaration and definition of the member function Request_data
{
cout << "How is the daily price?"<< endl;
cin >> DailyPrice;
cout << "What is the weight of the animal? " << endl;
cin >> Weight;
}
void Calculate_revenue() //Declaration and definition of the member function Calculate_revenue
{
Revenue = Weight* DailyPrice;
cout << "Revenue: " << Revenue <<endl;
}
class Animal {
private:
float Revenue;
float Weight;
float DailyPrice;
public:
void Request_data() // Declaration and definition of the member function Request_data
{
cout << "How is the daily price?" << endl;
cin >> DailyPrice;
cout << "What is the weight of the animal? " << endl;
cin >> Weight;
}
void Calculate_revenue() // Declaration and definition of the member function Calculate_revenue
{
Revenue = Weight * DailyPrice;
cout << "Revenue: " << Revenue << endl;
}
};
int main()
{
Animal animals[2];
animals[0].Request_data();
animals[0].Calculate_revenue();
int main() {
Animal animals[2];
animals[0].Request_data();
animals[0].Calculate_revenue();
animals[1].Request_data();
animals[1].Calculate_revenue();
animals[1].Request_data();
animals[1].Calculate_revenue();
cout << endl << endl;
cout << endl << endl;
return 0;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment