coin change program??

This is a discussion on coin change program?? within the C++ Programming forums, part of the General Programming Boards category; For some reason, I cannot think of the algorithm behind making this program. I have thought it through several times; ...

  1. #1
    kelly
    Guest

    coin change program??

    For some reason, I cannot think of the algorithm behind making this program. I have thought it through several times; however, it just doesn't make sense. Could someone lead my through the program, by means of some seudocode or actual code or something? Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Perhaps you could specify what your program needs to do in more detail and I'll try to help out with an algorithm.

    -Prelude
    My best code is written with the delete key.

  3. #3
    kelly
    Guest
    Well, for example if the program promted the user to enter an amount like 95 cents, the program would display 3 quartes, and 2 dimes, which is the most efficient way of giving change. IF the user enters more than 99 cents, it will give the user en error and loop.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Code:
    IF value <= 99
      WHILE value > 0
        IF value >= 25
          quarters = quarters + 1
          value = value - 25
        ELSE IF value >= 10
          dimes = dimes + 1
          value = value - 10
        ELSE IF value >= 5
          nickels = nickels + 1
          value = value - 5
        ELSE
          pennies = pennies + 1
          value = value - 1
      LOOP
    ELSE
      PRINT error message
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. make change program help
    By Rob4226 in forum C++ Programming
    Replies: 8
    Last Post: 02-20-2008, 01:58 PM
  2. Problems with a simple coin flipping program
    By Thileepan_Bala in forum C Programming
    Replies: 14
    Last Post: 01-18-2008, 08:33 PM
  3. change the program into installable package
    By mr_empty in forum Windows Programming
    Replies: 3
    Last Post: 12-03-2007, 02:06 AM
  4. Change of base program
    By cdonlan in forum C Programming
    Replies: 2
    Last Post: 01-17-2005, 04:51 PM
  5. Replies: 2
    Last Post: 09-04-2001, 03:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21