mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-19 15:59:56 +00:00
55 lines
858 B
C++
55 lines
858 B
C++
#include<iostream>
|
|
#include <cstdlib>
|
|
|
|
using namespace std;
|
|
|
|
class Tier
|
|
{
|
|
|
|
private:
|
|
float Einnahme;
|
|
float Gewicht;
|
|
float Tagespreis;
|
|
|
|
void Daten_abfragen() //Deklaration und Definition der Methode Daten_abfragen
|
|
{
|
|
cout << "Wie steht der Tagespreis? " << endl;
|
|
cin >> Tagespreis;
|
|
cout << "Wie ist das Gewicht? " << endl;
|
|
cin >> Gewicht;
|
|
}
|
|
|
|
public:
|
|
//Konstruktor
|
|
Tier()
|
|
{
|
|
Daten_abfragen();
|
|
};
|
|
Tier(float g, float t):Gewicht(g), Tagespreis(t){ }
|
|
|
|
//Methode
|
|
void Einnahme_berechnen() //Deklaration und Definition der Methode Einnahme_berechnen
|
|
{
|
|
Einnahme = Gewicht*Tagespreis;
|
|
cout << "Einnahme: " << Einnahme << endl;
|
|
}
|
|
|
|
};
|
|
|
|
int main()
|
|
{
|
|
Tier schwein(19,2.5);
|
|
cout << "Schwein ";
|
|
schwein.Einnahme_berechnen();
|
|
|
|
Tier kuh;
|
|
cout << "Kuh ";
|
|
kuh.Einnahme_berechnen();
|
|
|
|
cout << endl << endl;
|
|
|
|
system("PAUSE");
|
|
return 0;
|
|
}
|
|
|