NEWBIE JAVA:

I have a simple java program to write which tells the user combination of coins that equals to the amount of change i.e:

user input 87
output:
3 quarters
1 dime
0 nickels
2 pennies

SIMPLE RIGHT?! - we'll my book shows the example BUT my confusion is how the program remembers the remainder which is passed to the next column of let say dime

i.e

originalAmount = amount;
quarters = amount /25;
amount = amount % 25; <---- this is confusing for me?!?! how can the integer = integer % 25
dimes = amount / 10; <--- HOW THE PROGRAM remembers the "remainder" instead of the original user input as the code it self tells you dimes = amount where "amount" is what user input NOT remainder. PLease help.
amount = amount % 10;
so on ....;


What I don't understand is HOW this algorithm works. I mean we have
int amount where user inputs the number we get the first calculation
amount/25 = how many quarters and then amount %25 WILL tell us about
the reminder. By looking at this piece of code I would say that the
system should start the calculation for the dimes again from the
original number since the code says dimes = amount/10 AND amount =
amount%10. My understanding is that the calculation should be done
from the original user input.

Book or code it self is not clear for me how the reminder is
"REMEMBERED" and then pass on to the next calculation>!?!?

UNLESS the code: amount=amount%25 gets the remainder so the next code under it is REQUIRED to read from the last prompt code - Please advise if I think right?

Please advise,
dk