code help

could any body give me any idea what is the best way to work out the change ie. in dollars from purchased goods.
I have got the price of the goods and the money tendered now I need the change given and to print out the notes and coins required that make up the change.

Any help would be great
Tom

Comments

  • First you need to figure out how many bills you need, 20,10,5,1, then quarters, dimes & nickles
    this should give you an idea of what to do.


    Change=CashTendering-Purchase
    REM FIGURE OIUT NUMBER OF TWENTIES
    while CHANGE>20 do
    NumberofTwenties=NumberofTwenties+1
    Change=Change-20
    enddo
    REM FIGURE OUT NUMBER OF TENS
    while CHANGE>10 do
    NumberofTens=NumberofTens+1
    Change=Change-10
    enddo
    REM FIGURE OUT NUMBER OF FIVES

    while CHANGE>5 do
    NumberofFives=NumberofFives+1
    Change=Change-5
    enddo
    REM FIGURE OUT NUMBER OF ONES
    while CHANGE>1 do
    NumberofOnes=NumberofOnes+1
    Change=Change-1
    enddo
    REM NOW FIGURE OUT THE COINS.


    NumberofQuarters=Change/0.25
    change=change-NumberofQuarters*0.25
    NumberofDimes=change/0.10
    Change=Change-NumberofDimes*0.10
    NumberofNickles=Change/0.05
    Change=Change-NumberofNickles*0.05
    NumberofPennies=CHANGE:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories