can u please help me to write a progam that convert one currency to another?
how to write a program in c++ to convert currency?
Collapse
X
-
Tags: None
-
Some days you just have to respond ....
Code:main() { float dollars; int want; printf("Input dollars: "); cin >> dollars; if (0. == dollars) { printf("give nothing, get nothing...\n"); exit(1); } else if (0. > dollars) { printf("I wrote input, not take!\n"); exit(2); } else if (1. > dollars) { printf("Well, you sure are a parsimonious one, aren't you?\n"); exit(3); } else { } printf("What do you want in return: 1 dollars, 2 nothing? "); cin >> want; if (1 == want) printf("Sure thing, here's your $%f.2 back, less my fee, of course.", (dollars - 0.50)); else if (2 == want) printf("Here you go ... a whole lot of nothing ...\n"); else printf("I guess you're sure ... here's your %d back. I'll keep the $%f.2 for the effort.", desire, dollars); return 0; }Comment
-
Do you have a list of exchange rates?
If not they will be in your local newspaper or Google.
Can you convert one currency to another using exchange rates and a pencil and paper? Write out the mechanism and then convert it to C++.
e.g. if 1.0 $A=1.68$Fiji
and 1.0 $A=6.8$HK
then 1.68$F=6.8$HK
or 1.0 $Fiji = 6.8/1.68 = 4.05$HK
You could use the switch and case: construction for these conversion constants.
If you post some code and say where you are having difficulties someone will help you.Comment
-
Some websites provide open access to text files containing exchange rate data.
These can be opened and parsed to get the data you require.
Most actually charge, but a free one is Timegenie.Comment
Comment