-
Money Conversion
In one of the excercieses that i'm doing it wan'ts me to write a program that asks the user to input an amount in dollars (5.67) and then converts that (5.67) to the old british style system of pounds shilling and pence (10.3.9). Here's some info
20 shilling = 1 pound
12 pence (pennies) = 1 shilling
240 pence (pennies) = 1 pound
interaction with the program might look like this:
//example
Enter amount in new style currency: 5.67 //example
Converted (pound, shilling, pence) = 10.3.9 //not right answer
I'm very confused on how to go about converting this. This is all the info that's given. If you have any suggestions plz write back. thanks
-
/ operator for integer division quotient.
% operator for integer division remainder.
all floting point values can be turned into integers with some creative maths :p
example...
Code:
int a = 25;
int quotient = a / 7;
int remainder = a % 7;
should have some clue now!:p
-
ummm..acually i dont' have any clue. :confused: Hey stoned coder. Man, it seemed like your always on. Your the first one the answer each of my question most of the time:D thanks. But, what you wrote didn't seem to strike a bell
-
in the mythical world of cprog the currency is the salem. There are 5 fordys to the salem and 10 volks to the fordy.
Code:
#include<iostream>
using namespace std; // for ease of my typing.U do the right thing.read faq namespace tut.
int main()
{
int total;
cout<<"Enter amount of volks....";
cin>>total;
int salems = total/50;
int remainder = total%50;
int fordys = remainder/10;
remainder %= 10;
cout<<endl<<"that is "<<salems<<" salems and "<<fordys<<" fordys and "<<remainder<<" volks"<<endl;
return 0;
}
Work out how that works and you will be on your way.
-
You will also need an exchange rate, i.e. how many pounds to the dollar. Since the actual exchange rate varies from day to day, consider prompting the user to input that. You can find the current rate at sites like this one:
http://www.xe.com/ucc/
-
>There are 5 fordys to the salem and 10 volks to the fordy.
What about the prelude? All I have are volks and they jingle too much. Of course, if I get more than 6 or 7 preludes to the fordy then they'll jingle too much too. We need a good table of exchange rates, do you have one handy? :D
p.s. I really would like some quzahs too, I have no doubt that the face of the coin is :mad:. Those would be fun to have.
-Prelude
-
those currencies are in common usage in cprog as u well know but they would have bloated the example so were left out for brevity....
My apologies to the forgotten :rolleyes:
-
Wow, is it really 5 fordys to the salem nowadays? Jeez I hate inflation. I remember back in the days when when one could get a whole cheeseburger and a cherry coke for only a volk and still have plenty of quzahs left over. Ahhh, the good ol' days.