I am still a beginner, I recently started learning C++. However I am writing a program that converts currencies. For example Dollars to Euros. However when I have them pick the number of the currency they want to convert the number 2 doesnt work. Here it is:
#include <iostream> using namespace std; int main() { int currency; float eurosdollars; float dollarseuros; cout<<"1.Dollars to Euros\n"<<endl; cout<<"2.Euros to Dollars\n"<<endl; cout<<"Please enter the number of the currency you want to convert: "; cin>>currency; if (currency==1) cout<<"Please enter the Dollars you would like to convert to Euros: "; cin>>eurosdollars; cout<<"You have entered "<<eurosdollars<<" dollars which is equal to "<<eurosdollars * 0.678518116<<" euros."<<endl; if (currency==2) cout<<"Please enter the Euros you would like convert to Dollars: "; cin>>dollarseuros; cout<<"You have entered "<<dollarseuros<<" Euros which is equal to "<<dollarseuros * 1.4738 <<" Dollars."<<endl; }
Right at the if (currency==2)
cout<<"Please enter the Euros you would like convert to Dollars: ";
cin>>dollarseuros; it never works when you type in 2 it doesn't go to that. It just stays the same even if you keep typing in 2.