Qbasicnews.com

Full Version: Making Change
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Can someone help me write a program in which you tell the computer the cost of an item you have purchased then input the amount of money you will hand the cashier, test to make sure you gave the cashier enough money to cover your purchase have the computer calculate the amount of change you should recieve, inform you of that amount, and give a breakdown by bill and by coin(amount of $100's 50's 10's quarters nickels etc) of what the cashier should hand you and ask if you need to purchase anything elseand throw in the 8% sales tax.
Could we see some proof that you aren't just trying to get a free homework assignment done for you? We can help you if you did something.
Show us the code you already have, and ask more specific questions, like:
How do I add two variables togheter, etc.

We will not do your homework, but we will hlep you in the right direction.
Quote:Can someone help me write a program in which you tell the computer the cost of an item you have purchased then input the amount of money you will hand the cashier, test to make sure you gave the cashier enough money to cover your purchase have the computer calculate the amount of change you should recieve, inform you of that amount, and give a breakdown by bill and by coin(amount of $100's 50's 10's quarters nickels etc) of what the cashier should hand you and ask if you need to purchase anything elseand throw in the 8% sales tax.

I won't do your homework for you, well maybe I will. :???:

Code:
INPUT "enter item ", item$
IF item$ = "ether" then price = 3.50
if item$ =  "potion then price = 4.50

That example tells how much an item can cost..

Code:
PRINT "Give me "; price; " for that "; item$
INPUT cash
IF cash = price then print "You payed the exact price for the item."
IF cash > price THEN
money = cash - price
PRINT "You need to give me "; money " money!"
END IF
IF cash < price THEN goto changeroutine 'i'll explain this in a bit

That tells if you have enough/too much/ or too little money.

Code:
change = price - cash
PRINT "You get this much change."

I'll leave the next two(hardest) parts up to you...
this is an assignment for my qbasic class but it isnt graded and offensive screenmae thank you but the last parts are the only ones i need so what you gave me was kind of useless but it was still helpful thanks Smile
Quote:We will not do your homework, but we will hlep you in the right direction.


@QPRGM: It doesn't matter if it's not graded. You do not learn anything if you have someone else do it for you. How about you post the code you have so far and we'll give you some more tips.
one addtion...

i'm not 100% sure, but i guess the following is right:

Coins: 25cent, 10cent, 5cent, 2cent, 1cent
Bills: 100Dollar, 50Dollar, 10Dollar, 1Dollar...

are there any other coins? bills? i forgot....cuz i'm from germany and the euro coins are slightly different valued...

anyways, here you go:

Code:
'change = cents

Dollar100% = change% \ 10000
change% = change% mod 10000

Dollar50% = change% \ 5000
change% = change% mod 5000

Dollar10% = change% \ 1000
change% = change% mod 1000

Dollar1% = change% \ 100
change% = change% mod 100

Cent25% = change% \ 25
change% = change% mod 25

Cent10% = change% \ 10
change% = change% mod 10

Cent2% = change% \ 2
change% = change% mod 2

Cent1% = change%

code is not tested, but you should get the idea^^

cheers
Quote:
Z!re Wrote:We will not do your homework, but we will hlep you in the right direction.


@QPRGM: It doesn't matter if it's not graded. You do not learn anything if you have someone else do it for you. How about you post the code you have so far and we'll give you some more tips.

Not neccesarily, if we give an example and explain how it was done(which I didnt do) he will still learn from it.

Anyways, since you got the coin part done for you I'll just do the sales tax thingy

[code]
'this is actually pretty easy, to find sales tax all you have to do is multiply
'the total price by the sales tax, which is 8%. So the equation would look like

tax = 0.08
INPUT "Enter total cash... "; total
total1 = total * tax
PRINT "The total price is "; total1
heres what i have
'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) <this is 1.08 then a parentheses not a face
cls
print "your change"
print chgn

now my problem is i want this program to tell me the dollars and cents that a cashier would give me ex: item is $20 + tax equals $21.60 with me? i give 25 my change is $3.40 now i want the computer to say i give you 3 $1 dollar bills and 4 dimes get it

here it is again $20*1.08%=21.60===>25-21.60=3.40 i get 3 $1 dollar bills and 4 dimes

can you help me with that??
Quote:[code]
'this is actually pretty easy, to find sales tax all you have to do is multiply
'the total price by the sales tax, which is 8%. So the equation would look like

tax = 0.08
INPUT "Enter total cash... "; total
total1 = total * tax
PRINT "The total price is "; total1

this would leave me with 8% of the actual price ex:20*.08=1.60 not 21.60 so this really doesnt help
Pages: 1 2