All pastes #93792 Raw Edit

taschenrechnertest

public cpp v1 · immutable
#93792 ·published 2006-07-20 19:29 UTC
rendered paste body
#include <iostream>#include <string>using namespace std;float Dividiere (float Zahl1, float Zahl2) { if(Zahl2==0){  return 1; } else {  return Zahl1/Zahl2; }}float Potenzrechnung (float Zahl, int Exponent) {float Ergebnis = Zahl; //ergebnis mit dem wert von der float variable Zahl initialisieren..for (int zaehler=1;zaehler<Exponent;zaehler++) { Ergebnis = Ergebnis * Zahl;}return Ergebnis;}float Multipliziere (float Zahl1, float Zahl2) {return Zahl1*Zahl2;}float Subtrahiere (float Zahl1, float Zahl2) {return Zahl1-Zahl2;}float Addiere (float Zahl1, float Zahl2) {return Zahl1+Zahl2;}int main() {string InputVar;float ein_zahl1, ein_zahl2;cout << "Bitte eingeben:\nAddieren\nSubtrahieren\nMultiplizieren\nDividieren\n\n";NeuEingabe:   // Einsprungpunkt für GoTo nach Falscheingabe bzw. Fertigstellung nach      // Rechnungcout << "Befehl: ";cin >> InputVar;if (InputVar == "Addieren") { cout << "Zahl 1:"; cin >> ein_zahl1; cout <<"Zahl 2:"; cin >> ein_zahl2;"\nErgebnis: " << Addiere(ein_zahl1,ein_zahl2) << "\n\n"; goto NeuEingabe;}else if (InputVar == "Subtrahieren") { cout << "Zahl 1:"; cin >> ein_zahl1; cout << "Zahl 2:"; cin >> ein_zahl2;"\nErgebnis: " << Subtrahiere(ein_zahl1,ein_zahl2) << "\n\n"; goto NeuEingabe;}else if (InputVar == "Multiplizieren") { cout << "Zahl 1:"; cin >> ein_zahl1; cout << "Zahl 2"; cin >> ein_zahl2;"\nErgebnis: " << Multipliziere(ein_zahl1,ein_zahl2) << "\n\n"; goto NeuEingabe;} else if (InputVar == "Dividieren") {  cout << "Zahl 1:"; cin >> ein_zahl1; cout << "Zahl 2:"; cin >> ein_zahl2;"\nErgebnis: " << Dividiere(ein_zahl1,ein_zahl2) << "\n\n"; goto NeuEingabe;}else if ((InputVar == "exit") || (InputVar == "Exit")) { return 1;} else {  cout << "Error! Unbekannter Befehl!\n\n";  goto NeuEingabe;}return 0;}