Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making Change
#11
my mistake... 8)

I gave you the tax percentage, not the actual price.

But you should be able to figure this out on your own.

Just add the tax to the total price to find the total total price.
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Reply
#12
'making change
cls
input "what is the price of the item you would like to purchase"; pri1
2 input "how much do you give the cashier?"; umon
if umon<pri then
goto 3
else goto 4
end if
3 print "i need more money"
goto 2
4 print "Your change is...."
chgn=umon-(pri1*1.08 )
dollar100=int(chgn/100) < here i added program
?????mod????? <i need it to show the remainder here to divide it further
cls
print "your change"
print chgn < here ill add the dollar100etc which will tell me the amount of bills i get

can anyone help now???
Reply
#13
GOTOs are really sloppy
also you have to make sure you dont count change twice (like lets say you have 100 cents. you dont want it to say
1 dollar
4 quarters
10 dimes
20 nickles
100 pennies

so you have to subtract from the total change and keep going
[syntax="QBASIC"]'making change
tax = 1.08
CLS
DO
INPUT "what is the price of the item you would like to purchase (w/o tax)"; itemprice
itemprice = itemprice * tax
PRINT "The price w/ tax is"; itemprice
INPUT "how much do you give the cashier?"; pay
CLS
IF INT(pay * 100) < INT(itemprice * 100) THEN PRINT "I need more money" ELSE EXIT DO
LOOP
change = pay - itemprice
total = INT(change * 100 + .5) ' make into cents rounding up
dollars = INT(total / 100) 'get the dollars
total = total - (dollars * 100)'subtract the amount of dollars (in cents) form the total
quarters = INT(total / 25) 'ect
total = total - (quarters * 25)
dimes = INT(total / 10)
total = total - (dimes * 10)
nickles = INT(total / 5)
total = total - (nickles * 5)
pennies = total
PRINT "Item Price:"; itemprice
PRINT "You paid:"; pay; ""
PRINT " Your change is"
PRINT dollars; "- Dollars"
PRINT quarters; "- Quarters"
PRINT dimes; "- Dimes"
PRINT nickles; "- Nickles"
PRINT pennies; "- Pennies"[/syntax]

:wink:


(yes i did give the whole code. i decided it would be easier this way instead of giving all the pieces.)
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)