gistlib
main.mfunction changeBreakdown(total) dollars = floor(total); remaining = total - dollars; quarters = floor(remaining / 0.25); remaining = remaining - (quarters * 0.25); dimes = floor(remaining / 0.1); remaining = remaining - (dimes * 0.1); nickels = floor(remaining / 0.05); remaining = remaining - (nickels * 0.05); pennies = remaining * 100; fprintf('Dollars: %d\nQuarters: %d\nDimes: %d\nNickels: %d\nPennies: %d\n', dollars, quarters, dimes, nickels, pennies); end 529 chars18 lines
function changeBreakdown(total) dollars = floor(total); remaining = total - dollars; quarters = floor(remaining / 0.25); remaining = remaining - (quarters * 0.25); dimes = floor(remaining / 0.1); remaining = remaining - (dimes * 0.1); nickels = floor(remaining / 0.05); remaining = remaining - (nickels * 0.05); pennies = remaining * 100; fprintf('Dollars: %d\nQuarters: %d\nDimes: %d\nNickels: %d\nPennies: %d\n', dollars, quarters, dimes, nickels, pennies); end
gistlibby LogSnag