From fc9f52f53320b021f242a86c399320ad4df56ccc Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 11 Apr 2025 10:57:58 +0200 Subject: [PATCH] Termin 3 aufgabe --- v3.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 v3.cpp diff --git a/v3.cpp b/v3.cpp new file mode 100644 index 0000000..ffdc964 --- /dev/null +++ b/v3.cpp @@ -0,0 +1,73 @@ +#include +#define EOF (-1) + +using namespace std; + +double addition(double ersteZahl, double zweiteZahl){ + double erg = ersteZahl + zweiteZahl; + cout << ersteZahl<< " + " << zweiteZahl << " = " << erg << endl; + return erg; +} + +double subtraktion(double ersteZahl, double zweiteZahl){ + int erg = ersteZahl - zweiteZahl; + cout << ersteZahl<< " - " << zweiteZahl << " = " <> operation; + + if (operation == '+') + { + pruef = true; + } else if (operation == '*') { + pruef = true; + } else if (operation == '/') { + pruef = true; + } else if (operation == '-') { + pruef = true; + } else { + cout << "Keine definierte Rechenoperation" << endl; + while ((clear = getchar()) != '\n' && clear != EOF) { } + } + } while (pruef == false); + + cout << "Erste Zahl:"; + cin >> ersteZahl; + cout << "Zweite Zahl:"; + cin >> zweiteZahl; + + switch (operation) { + case '+': + addition(ersteZahl, zweiteZahl); + case '-': + subtraktion(ersteZahl, zweiteZahl); + case '*': + multiplikation(ersteZahl, zweiteZahl); + case '/': + while (zweiteZahl == 0){ + cout << "Man kann nicht durch 0 teilen. Geben Sie eine neue zweite Zahl ein:"; + cin >> zweiteZahl; + } + division(ersteZahl, zweiteZahl); + } +} \ No newline at end of file