Urgent help! how do i convert this?..
Posted
by sil3nt
on Stack Overflow
See other posts from Stack Overflow
or by sil3nt
Published on 2010-03-14T04:51:44Z
Indexed on
2010/03/14
4:55 UTC
Read the original article
Hit count: 202
Hey there, this is part of a question i got in class, im at the final stretch but this has become a major problem. In it im given a certain value which is called the "gold value" and it is 40.5, this value changes in input.
and i have these constants
const int RUBIES_PER_DIAMOND = 5; // relative values. *
const int EMERALDS_PER_RUBY = 2;
const int GOLDS_PER_EMERALDS = 5;
const int SILVERS_PER_GOLD = 4;
const int COPPERS_PER_SILVER = 5;
const int DIAMOND_VALUE = 50; // gold values. *
const int RUBY_VALUE = 10;
const int EMERALD_VALUE = 5;
const float SILVER_VALUE = 0.25;
const float COPPER_VALUE = 0.05;
which means that basically for every diamond there are 5 rubies, and for every ruby there are 2 emeralds. So on and so forth.
and the "gold value" for every diamond for example is 50 (diamond value = 50) this is how much one diamond is worth in golds.
my problem is converting 40.5 into these diamonds and ruby values. I know the answer is 4rubies and 2silvers but how do i write the algorithm for this so that it gives the best estimate for every goldvalue that comes along??
please help!, im at my wits end
© Stack Overflow or respective owner