GonzoReal's comments

  GonzoReal   ignore (0)   2017 Jun 13, 12:18am   ↑ like (1)   ↓ dislike (1)   quote   flag        


Dusk at Squaw June 11

  GonzoReal   ignore (0)   2017 Jul 27, 8:06pm   ↑ like (2)   ↓ dislike (0)   quote   flag        

Pseudocoded without arrays or loops using mod function. Not very elegant but time complexity is constant for any input.

amount = 0
remainder=0
quarters=0
dimes=0
nickels=0
pennies=0

Input amount from user
amount =amount X 100;. Get rid of decimals
remainder = amount mod 25
amount = amount - remainder
quarters = amount /25
amount = remainder
remainder = amount mod 10
amount = amount - remainder
dimes = amount / 10
amount = remainder
remainder = amount mod 5
amount =amount - remainder
nickels = amount / 5
pennies = remainder
output "Quarters =" quarters
output "Dimes =" dimes
output "Nickels =" nickels
output "Pennies =" pennies

about   best comments   contact   one year ago   suggestions