writing code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gruvon69
    New Member
    • Oct 2006
    • 2

    writing code

    I am trying to write code for a project that deals with making change from money. I put the money presented and the total amount, but I can't get the change to show up in the list box? The change has to be broken down by fifties, twenties, tens, etc. Any Help?
  • Metalzed
    New Member
    • Sep 2006
    • 27

    #2
    Originally posted by gruvon69
    I am trying to write code for a project that deals with making change from money. I put the money presented and the total amount, but I can't get the change to show up in the list box? The change has to be broken down by fifties, twenties, tens, etc. Any Help?
    Dont realy understand what you want..
    What syntax are you writing in

    Splitting up money could be done with a code like this (dont know if it is the best way


    Code:
             int money=1234;
             int fifties, twenties, tens;
    
            
              fifties= Convert.ToInt32(Math.Floor((money/ 50)));
              money= money- fifties* 50;
    
              twenties= Convert.ToInt32(Math.Floor(money/ 20));
              money= money- twenties*20;
    
              tens= Convert.ToInt32(Math.Floor(money/ 10));
              money= money- tens*10;
    Money=1234 will give the values
    fifties =24
    twenties=1
    tens=1
    money=4 (the rest)

    hope it helped

    Comment

    Working...