I have been working on a change program for one of my classes that I
am taking. I got it to work, but I had a section of code that I was
trying to make more efficent. The section of code is below
m_twentydollars = Math.Floor(m_amount / 2000)
m_tendollars = Math.Floor((m_amount Mod 2000) / 1000)
m_fivedollars = Math.Floor((m_amount Mod 1000) / 500)
m_onedollar = Math.Floor((m_amount Mod 500) / 100)
m_halfdollars = Math.Floor((m_amount Mod 100) / 50)
m_quarters = Math.Floor((m_amount Mod 50) / 25)
m_dimes = Math.Floor((m_amount Mod 25) / 10)
m_nickels = Math.Floor((m_amount - (2000 *
m_twentydollars) - _
(1000 * m_tendollars) - (500 * m_fivedollars) - _
(100 * m_onedollar) - (50 * m_halfdollars) - (25 *
m_quarters) - _
(10 * m_dimes)) / 5)
m_pennies = Math.Floor((m_amount Mod 5) / 1)
Is there a way to shorten the equation for m_nickles? This was the
only way I could get m_nickels to work out right.