#include <iostream>
#include "funktionen.h"
using namespace std;
int rechnung()
{
cout << "Please choose the operator you want to calculate with" << endl;
int eingabe1;
int eingabe2;
int eingabe;
int dummy;
char zeichen;
char again;
cin >> zeichen;
cout << endl << "1. Eingabe: ";
cin >> eingabe1;
cout << endl << "2. Eingabe: ";
cin >> eingabe2;
switch (zeichen)
{
case '+':
eingabe=eingabe1 + eingabe2;
break;
case '-':
eingabe=eingabe1 - eingabe2;
break;
case '*':
eingabe=eingabe1 * eingabe2;
break;
case '/':
eingabe=eingabe1 / eingabe2;
break;
}
cout << endl << "Das Ergebnis ist | " << eingabe << " | " << endl << endl;
cout << "Wanna calculate again? ";
cin >> again;
while(again=='Y')
{
rechnung();
}
return 0;
}
So this is my code in an implementation file. My problem is, that the main program always loops the whole "rechnung()" function even though I don't type "Y" into the console once it asks for it. In the beginning, when I type something else than "Y", then the console closes (as it shall) but if I do a calculation, type "Y", do another calculation and type "k" for example, it also starts from the beginning of "rechnung()". Why does it do so? I mean I told him that he shall only recall the "rechnung()" if the character input is "Y".