Why is the last calculation printing out the wrong calculation. here is my code:
System.out.print("Enter total cost: ");
double totalCost = input.nextDouble();
System.out.print("The Customer has paid: ");
double customerAmount = input.nextDouble();
//Calculations
double changeOwed = customerAmount - totalCost;
System.out.println("Change owed: $"+(int)changeOwed);
int amountFifty = (int)changeOwed/50;
System.out.println("How many $50 notes = " +amountFifty);
int takeAway = (int)changeOwed - (amountFifty * 50);
int amount20 = takeAway / 20;
System.out.println("How many $20 notes = " +amount20);
int amount10 = (takeAway - amount20*20) / 10;
System.out.println("How many $10 notes = " +amount10);
enter code here
int amount5 = (takeAway - amount10*10) / 5;
System.out.println("How many $5 notes = " +amount5);
int amount2 = (takeAway - amount5*5) / 2;
System.out.println("How many $2 notes = " +amount2);
int amount1 = (takeAway - amount2*2) /1;
System.out.printl
n("How many $1 notes = " +amount1);