Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VHB C++ DE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VHB Cpp
VHB C++ DE
Commits
e793b42d
Commit
e793b42d
authored
7 months ago
by
Rudi Buss
Browse files
Options
Downloads
Patches
Plain Diff
Update Solution Exercise 2 - Animals.cpp
parent
bc435586
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Part 1/7. Classes and objects/Solutions/Solution Exercise 2 - Animals.cpp
+29
-31
29 additions, 31 deletions
...s and objects/Solutions/Solution Exercise 2 - Animals.cpp
with
29 additions
and
31 deletions
Part 1/7. Classes and objects/Solutions/Solution Exercise 2 - Animals.cpp
+
29
−
31
View file @
e793b42d
...
...
@@ -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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment