### terminating loop I am trying to write a simple money exchange program. The following should happen: User enters maximum five currency-exchange rate pairs. If they would like to stop entering currencies they may enter x. It calculates the equivalent value. If the user enter -1 it shod stop calculating.

The progream doesn't go for the next loop and when we press character x nothing happens. Can I have some help about it please?

 ``12345678910111213141516171819202122232425262728293031`` ``````#include #include using namespace std; int main(){ string currency; double rate{0}; double pound{0}; double resoult{0}; int counter{1}; cout << "Enter max.5 currency/ exchange rate for one Pound" << endl; while(counter <=5){ getline (std::cin, currency); cin >> rate; cout << "\nHow many Pounds do you want to exchange?"; cin >> pound; if(pound == -1){ break; } resoult = pound*rate; cout << "\nExchanged currency: " << currency << " In pounds: " << resoult; if(currency == "x"){ break; } counter++; } } `````` If i understand correctly, your testing if currency equals x, but your if statement is way at the bottom, move it under your getline and it should work. the way you have it now, If the user presses x, it will still execute the rest of your cin inputs before reaching the if statement that tests for x being input.
Last edited on I made some changes, but the problem is from the second loop it doesn`t let the user enter anything, it just makes some calculations and the result is 0. Can I have some help please?

 ``12345678910111213141516171819202122232425262728293031323334`` ``````#include #include using namespace std; int main(){ string currency; double rate{0}; double pound{0}; double resoult{0}; int counter{1}; cout << "Enter max.5 currency/ exchange rate for Pounds" << endl; getline (cin, currency); cin >> rate; while(currency != "-1" && counter <= 4){ cout << "\nHow many Pounds do you want to exchange?"; cin >> pound; resoult = pound*rate; cout << "\nExchanged currency: " << currency << " In pounds: " << resoult; cout << "\n\nEnter max.5 currency/ exchange rate for Pounds" << endl; getline (cin, currency); cin >> rate; counter++; } } ``````