I'm trying to convert the total amount left over after a purchase into the correct amount of change. I have written a program but for some reason the dimes go insane and it randomly generates nickels. Can someone tell me why this isn't working?

Code:#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { float amountdue; printf( "Please enter your amount due(in dollars): " ); scanf( "%f", &amountdue ); printf( "You have entered %.2f dollars.\n", amountdue ); float amountgiven; printf( "Please enter the amount given(in dollars): " ); scanf( "%f", &amountgiven ); printf( "You have entered %.2f dollars.\n", amountgiven ); float remaining; remaining = amountgiven-amountdue; if ( remaining < 0 ) { printf( "You do not have enough money!\n" ); } float dollars; float quarters; float dimes; float nickels; float pennies; dollars = 0; quarters = 0; dimes = 0; nickels = 0; pennies = 0; printf ( "You will recieve %.2f back.", remaining ); while ( remaining >= 1 ) { remaining = ( remaining - 1 ); dollars = ( dollars + 1 ); } printf ( "Amounting to: %.0f dollars,", dollars ); while ( remaining >= .25 ) { remaining = ( remaining - .25 ); quarters = ( quarters + 1 ); } printf ( " %.0f quarters,", quarters ); while ( remaining >= .1 ) { remaining = ( remaining - 0.1 ); dimes = ( dimes + 1 ); } printf ( " %.0f dimes,", dimes ); while ( remaining >= .05 ) { remaining = ( remaining - 0.05 ); nickels = ( nickels + 1 ); } printf ( " %.0f nickels,", nickels ); while ( remaining >= .01 ) { remaining = ( remaining - 0.01 ); pennies = ( pennies + 1 ); } printf ( " and %.0f pennies." , pennies ); system("pause"); exit (0); }