#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
usingnamespace std;
int main()
constexprdouble yen to dollar=2.3;
constexprdouble euro to dollar=1.38;
constexprdouble pound to dollar=0.6;
double yens=1;
double euros=1;
double pounds=1;
string unit;
unit=pound or yen or euro;
cout<<"Please choose if you would like to convert yens,euros or pounds into dollars";
cin>>yen>>euro>>pound>>unit;
cout<<"How many << unit << you would like to convert?";
cin>>unit;
if(unit == yen)
cout <<yen<< "dollars == "<<yen to dollar*yen<<"dollars\n";
elseif (unit == euro)
cout<<euro<<"dollars == "<<euro to dollar*euro<<"dollars\n";
elseif (unit == euro)
cout<<euro<<"dollars == "<<euro to dollar*euro<<"dollars\n";
else
cout<<"Sorry, I don`t know a unit called ' "<<unit<<" '\n";
}
Now that's too much , you've been asking for help in every exercise .( and that too mostly simple syntactical errors and problems because you don't understand the concept well.)
I have been reading a book, so why to change tack by sudden to online tutorials?
I admit that in the above code I make basic mistakes and tried to fix it up. I don`t have answers to those exercises. Here is the code improved but still does not compile:
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
usingnamespace std;
int main()
constexprdouble yens_in_dollar=2.3;
constexprdouble euros_in_dollar=1.38;
constexprdouble pounds_in_dollar=0.6;
double number=1; // number in yens,euros or pounds
string value; // Specifies a string called value
value= " ";
cout<<"Please choose what value (yen,euro or pound) would you like to change into dollars and choose number";
cin>>number>>value;
if(value == "yen")
cout <<number<<"yens == "<<yens_in_dollar*number<<"dollars\n";
elseif (value == "euro")
cout<<number<<"euros == "<<euros_in_dollar*number<<"dollars\n";
elseif (value == "pound")
cout<<number<<"pounds == "<<pounds_in_dollar*number<<"dollars\n";
else
cout<<"Sorry, I don`t know a value called " <<value<< "\n";
}
Well, I didn't knew you were reading a book , but anyway I was in the impression that your basics aren't clear yet ,
not to be sound discouraging. My point is that you didn't try too hard and quickly posted it here , while you solved those small issues yourself in a few minutes that won't help anyone if you give up too soon , look again at the chapters , examples ...
Recheck each statements and line , programming is not easy , you have to keep patience and with time , you will learn the compiler's error messages and figure things yourself but don't give up on every small issue and try figuring things yourself.