mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2026-06-29 01:23:21 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int Gewicht=0; // 3 globale Variablenen deklarieren und initialisieren
|
||||
float Tagespreis=0;
|
||||
float Einnahme=0;
|
||||
|
||||
void Daten_abfragen() //Deklaration und Definition der Methode Daten_abfragen
|
||||
{
|
||||
cout << "Wie ist das Gewicht? " << endl;
|
||||
cin >> Gewicht;
|
||||
cout << "Wie steht der Tagespreis? " << endl;
|
||||
cin >> Tagespreis;
|
||||
}
|
||||
|
||||
void Einnahme_berechnen() //Deklaration und Definition der Methode Einnahme_berechnen
|
||||
{
|
||||
Einnahme = Gewicht * Tagespreis;
|
||||
cout << "Einnahme: " << Einnahme<<endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
//Methodenaufrufe
|
||||
Daten_abfragen();
|
||||
Einnahme_berechnen();
|
||||
|
||||
cout << endl << endl;
|
||||
system("PAUSE");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
float quadrieren(float); //Deklaration der Funktion quadrieren. Übergabe ist eine Dezimalzahl, Rückgabe ist das Quadrat der übergebenen Zahl
|
||||
void kreisflaeche(float radius); //Deklaration der Funktion kreisflaeche. Übergabe ist eine Dezimalzahl (Radius), keine Rückgabe, gibt Kreisfläche aus
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
float quad_zahl;
|
||||
float radius;
|
||||
|
||||
cout << "Bitte geben Sie eine Zahl zum Quadrieren ein: ";
|
||||
cin >> quad_zahl;
|
||||
cout << endl << "Ergebnis Quadratzahl: " << quadrieren(quad_zahl) << endl << endl;
|
||||
|
||||
cout << "Bitte geben Sie einen Radius ein: ";
|
||||
cin >> radius;
|
||||
kreisflaeche(radius);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
float quadrieren(float zahl)
|
||||
{
|
||||
return zahl * zahl; //Zahl quadrieren
|
||||
}
|
||||
|
||||
void kreisflaeche(float r)
|
||||
{
|
||||
const float pi = 3.14;
|
||||
cout << endl << "Ergebnis Kreisfl\204che: " << quadrieren(r)*pi; //Kreisfläche berechnen und ausgeben
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user