creating a program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pazn16
    New Member
    • Apr 2008
    • 1

    creating a program

    I'm having trouble creating a program for this. I'am fairly new to C# so I don't really know exactly what to do.

    Create a C# program which prompts to the user to enter some dollar and cent amount. Then display the smallest collection of coins that would make that amount. For example, if the user enters 2.43, the result would be: 2 dollars, 1 quarter, 1 dime, 1 nickel, and 3 pennies.
    Last edited by sicarie; Apr 8 '08, 06:36 PM. Reason: Moved to .NET Forum
  • jg007
    Contributor
    • Mar 2008
    • 283

    #2
    Originally posted by pazn16
    I'm having trouble creating a program for this. I'am fairly new to C# so I don't really know exactly what to do.

    Create a C# program which prompts to the user to enter some dollar and cent amount. Then display the smallest collection of coins that would make that amount. For example, if the user enters 2.43, the result would be: 2 dollars, 1 quarter, 1 dime, 1 nickel, and 3 pennies.
    I haven't got any code for this but what about converring the amount to cents, then dividing the amount by the largest coin however appropriate and getting the remainder then going on to the next largest denomination and deviding it by this and so on.

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      had a quick play and did some rough VB code, I have left constants in although not really needed, sorry not very sure of C# otherwise I would have done some code for this.

      There are probably quicker ways of doing this also :)
      -REMOVED CODE -
      Last edited by Plater; Apr 8 '08, 09:12 PM. Reason: removed HW answer

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        This is a homework assignment. Which we do not answer.
        However, you have been given more then enough help already to solve this problem.
        If you have any specific troubles, you can come back and reply to this post with the question.

        Comment

        • balabaster
          Recognized Expert Contributor
          • Mar 2007
          • 798

          #5
          Oops, shouldn't have answered this...

          Comment

          • jg007
            Contributor
            • Mar 2008
            • 283

            #6
            Originally posted by balabaster
            Oops, shouldn't have answered this...

            sorry, I am LONG out of school so tend to just answer posts on automatic and did not even really think about it being a coursework assignment so hope that that doesn't get counted against me :)

            Comment

            • balabaster
              Recognized Expert Contributor
              • Mar 2007
              • 798

              #7
              Originally posted by jg007
              sorry, I am LONG out of school so tend to just answer posts on automatic and did not even really think about it being a coursework assignment so hope that that doesn't get counted against me :)
              Me too...I wrote a whole class in VB and C# that allows all sorts of nifty stuff like defining your currency separately from the code, auto-calculation of currency denominations so you can have currency of bases other than 100...so it worked for Lira and all sorts. Then I realised that Plater was right and removed it all again. I kept the code for future reference though.

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                YEa. I know how sometimes these "projects" sound nifty fun and as an experianced coder you can do the whole thing real fast. Hard not to "show it off".

                Comment

                • jg007
                  Contributor
                  • Mar 2008
                  • 283

                  #9
                  Originally posted by Plater
                  YEa. I know how sometimes these "projects" sound nifty fun and as an experianced coder you can do the whole thing real fast. Hard not to "show it off".
                  "Experience d Coder" !!!!!!! - not quite LOL

                  most of the questions I answer so that I can work out how to do them and then add the code to my collection.

                  I don't know that much code but I find that I learn easier if I have a specific aim so some of these questions prompt me to try and work out how to do things, I also tend to learn quite a lot by trying to work out what other peoples code does :)

                  Comment

                  Working...