Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help with a food program in turing
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Miko99




PostPosted: Tue May 27, 2003 7:02 pm   Post subject: Need help with a food program in turing

Ok. I have been struggling with this. I need to make a program that allows the user to buy their lunch. They pick from a menu what they want and then the computer spits out what their Bill is. They type in the size of the bill they will use ($50,$20,$10,$5 etc.) and the computer calculates how much change you will get. It tells the exact number of quarters, dollars, toonies, dimes, nickles, penny's, 5's, 10's (you get the point lol) that you will need. I need help with this. PLEASE HELP!!
Sponsor
Sponsor
Sponsor
sponsor
Asok




PostPosted: Tue May 27, 2003 7:04 pm   Post subject: (No subject)

ok general rule of thumb. If your asking for help we have to assume you've done some work on it as such post your code. No one here is going to write the entire program for you. On top of that, this is probably an assignment, handing someone elses work in is considered plagerism and will not be tollerated.
Tony




PostPosted: Tue May 27, 2003 7:10 pm   Post subject: (No subject)

some sujestions though...

use arrays to store your lists of food items and another array for prices... have a variable to count the total...

as for the change, its same as converting numbers to binary... find the largest change(or even bill) you can fit in the remainder of the change to give out, untill you get down to pennies.

such as for $1.67
its $1, 2 $0.25, $0.1, $0.05, 2 $0.01
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Miko99




PostPosted: Tue May 27, 2003 7:12 pm   Post subject: (No subject)

Actually i just cant get it to display the change part.
void




PostPosted: Tue May 27, 2003 8:07 pm   Post subject: (No subject)

easy...use mod..what does the bill minus price equal?...take that...mod it by 2 (toonies), then subtract that number times two from the change, then mod it by 1 and repeat until you reach 0.01...then you will be done...understand?
Miko99




PostPosted: Tue May 27, 2003 8:19 pm   Post subject: (No subject)

Heres my code so far. Please correct because i cant figure it out!

code:
var tens,tens1,nickles,nickles1,fives,fives1,toonies,toonies1,loonies,loonies1,quarters,quarters1,dimes,dimes1,pennys,pennys1:int
var main:string
var A:real:=300
var B:int:=340
var C:int:=240
var D:int:=500
var E:int:=300
var side:string
var F:int:=100
var G:int:=200
var H:int:=200
var I:int:=150
var J:int:=100
var drink:string
var K,N:int:=100
var L:int:=150
var M:int:=200
var O:int:=135
var total,choice,change:int

 

loop
put "Please Select one of the following main courses"
put "A = Hamburger"
put "B = Cheeseburger"
put "C = Chicken Burger"
put "D = Submarine"
put "E = Salad"
get main
exit when main = A or main = B or main =  or main = D or main = E
end loop


loop
put "please select one of the following side dishes"
put "F = 2 Cookies"
put "G = Fries"
put "H = Pasta"
put "I = Mashed Potato's"
put "J = Baked Potatoes"
get side
exit when side = F or side = G or side = H or side = I or side = J
end loop


loop
put "please select a drink"
put "K = Pop"
put "L = Chocolate Milk"
put "M = Gatoraid/Poweraid"
put "N = Bottled Water"
put "O = Slush Puppy"
get drink
exit when drink = K or drink = L or drink = M or drink = N or drink = O
end loop


total:=drink+side+main
put "Your total comes to ",total
put "What bill will you use to pay for this?"
get choice

change:=choice-total

if (change>1000) then
loop
tens1:=change-1000
tens:=tens+tens1
change:=change-1000
exit when change < 1000
end loop


put "you will need ",tens," tens"
end if
if (change>500) then
loop
fives1:=change-500
fives:=fives+fives1
change:=change-500
exit when change < 500
end loop

put "you will need ",fives," fives"
end if
if (change>200) then
loop
toonies1:=change-200
toonies:=toonies+toonies1
change:=change-200
exit when change < 200
end loop

put "You will need ",toonies," toonies"
end if
if(change>100) then
loop
loonies1:=change-100
loonies:=loonies+loonies1
change:=change-100
exit when change < 100
end loop

put "You will need ",loonies," loonies"
end if
if (change>25) then
loop
quarters1:=change-25
change:=change-25
exit when change < 25
end loop

put "You will need ",quarters," quarters"
end if
if (change>10) then
loop
dimes1:=change-10
dimes:=dimes+dimes1
change:=change-10
exit when change < 10
end loop
end if
if (change>5) then
loop
nickles1:=change-5
nickles:=nickles+nickles1
change:=change-5
exit when change < 5
end loop
put "You will need ",nickles," nickles"
end if

if (change > 1) then
loop
pennys1:=change-1
pennys:=pennys+pennys1
change:=change-1
exit when change < 1
end loop
put "You will need ",pennys," pennys"
end if









void




PostPosted: Tue May 27, 2003 8:34 pm   Post subject: (No subject)

why do the foods cost hundreds??!?!?!?!?
Tony




PostPosted: Tue May 27, 2003 8:35 pm   Post subject: (No subject)

maybe he's from russia Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
void




PostPosted: Tue May 27, 2003 8:40 pm   Post subject: (No subject)

lolz...i dont think russia uses toonies....
Tony




PostPosted: Tue May 27, 2003 8:43 pm   Post subject: (No subject)

no, its the exchange rate... its something like $1 = 20 rubles...

so a 100 is $5... hmm...

you can buy a submarine for $25... ya, he must be from russia Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
JSBN




PostPosted: Tue May 27, 2003 8:44 pm   Post subject: (No subject)

That better be the best damn burger & cookies that i ever had Confused
void




PostPosted: Tue May 27, 2003 8:51 pm   Post subject: (No subject)

LMFAO how do u use strint?
Tony




PostPosted: Tue May 27, 2003 9:00 pm   Post subject: (No subject)

code:

var number:int
var word:string := "1"
number := strint(word)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Miko99




PostPosted: Tue May 27, 2003 9:04 pm   Post subject: (No subject)

i know this is all funny but it really doesn't help. lol. the food will be divided by 100 when i print the total out.
Homer_simpson




PostPosted: Tue May 27, 2003 9:05 pm   Post subject: (No subject)

hehe i remeber doing the exact program a long time ago(5-6 years ago) but u wouldn't pick from any menu... u'd enter the price and the bill...i did it with turbo pascal(Oh memories =Þ)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 29 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: