I am having a very hard time making this program work right, I am sort of lost and I was wondering if I might get some advice.
This is what I have so far but I have a rounding error when I use the amount 10.03:
[CODE=java]public class Money
{
public static void main(String[] args)
{
double TOTAL_AMOUNT = 10.03;
int money = (int)(TOTAL_AMO UNT * 100);
System.out.prin tln("Your money amount " + TOTAL_AMOUNT + " consists of");
System.out.prin tln("\t" + (money / 100) + " dollars");
money = money % 100;
System.out.prin tln("\t" + (money / 25) + " quarters");
money = money % 25;
System.out.prin tln("\t" + (money / 10) + " dimes");
money = money % 10;
System.out.prin tln("\t" + (money / 5) + " nickels");
money = money % 5;
System.out.prin tln("\t" + (money / 1) + " pennies");
}
}[/CODE]
I know Math.round() is a useful class but can't figure how to put it in my program
This is what I have so far but I have a rounding error when I use the amount 10.03:
[CODE=java]public class Money
{
public static void main(String[] args)
{
double TOTAL_AMOUNT = 10.03;
int money = (int)(TOTAL_AMO UNT * 100);
System.out.prin tln("Your money amount " + TOTAL_AMOUNT + " consists of");
System.out.prin tln("\t" + (money / 100) + " dollars");
money = money % 100;
System.out.prin tln("\t" + (money / 25) + " quarters");
money = money % 25;
System.out.prin tln("\t" + (money / 10) + " dimes");
money = money % 10;
System.out.prin tln("\t" + (money / 5) + " nickels");
money = money % 5;
System.out.prin tln("\t" + (money / 1) + " pennies");
}
}[/CODE]
I know Math.round() is a useful class but can't figure how to put it in my program
Comment