I'm currently developing a small program for currency conversion, which will ask the amount in pounds then converts it to dollars with least number of notes and coins used.
most of the program is complete but im having a slight problem with converting the amount in Cent which is a double (amountCentD) to int (amountCentI) so i get rounded up value, i have used the following :
amountCentI = (int)amountCentD;
but it rounds i.e. 12.99999 to 12 and not to 13.
i have tried the following as well :
amountCentI = Math.rint(amountCentD);
but i get an error mentioning possible loss of precision.