Posted: Tue May 27, 2003 9:09 pm Post subject: (No subject)

long live pascal

Sponsor Sponsor

void

Posted: Tue May 27, 2003 9:22 pm Post subject: (No subject)

i think this is what your looking for mr.im too lazy to try...

code:

var names : array 1 .. 15 of string := init ("Hamburger", "Cheese Burger",
"Chicken Burger", "Submarine", "Salad", "2 Cookies", "Fries", "Pasta",
"Mashed Potatoes", "Baked Potatoes", "Pop", "Chocolate Milk",
"Gatorade/ Powerade", "Water", "Slush Puppy")
var prices : array 1 .. 15 of real := init (3, 3.4, 2.4, 5, 3, 1, 2, 2, 1.5,
1, 1, 1.5, 2, 1, 1.35)
var choice : array 1 .. 3 of int
var total : real := 0
var bill : real
var change : real
var t, l, q, d, n, p : real := 0
put "Main Dishes Prices"
for a : 1 .. 5
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
get choice (1)
for a : 6 .. 9
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
put "10-", names (10) : 20, prices (10) : 0 : 2
get choice (2)
for a : 11 .. 15
put a, "-", names (a) : 20, prices (a) : 0 : 2
end for
get choice (3)
total := prices (choice (1)) + prices (choice (2)) + prices (choice (3))
for a : 1 .. 3
put names (choice (a)) : 23, prices (choice (a)) : 0 : 2
end for
put "--------------------------"
put "TOTAL:" : 22, total : 0 : 2
put "Enter Bill Being Used:$" ..
get bill
if bill = 100 or bill = 50 or bill = 20 or bill = 10 or bill = 5 then
elsif bill not= 100 or bill not= 50 or bill not= 20 or bill not= 10 or
bill not= 5 then
put "YOU IDIOT THAT IS NOT A BILL"
put "TERMINATING PROGRAM DUE TO STUPIDITY"
end if
change := bill - total
cls
t := change div 2
change := change - (t * 2)
l := change div 1
change := change - (l * 1)
q := change div .25
change := change - (q * 0.25)
d := change div .1
change := change - (d * 0.1)
n := change div .05
change := change - (n * 0.05)
p := change div .01
change := change - (p * 0.01)
put "Toonies :", t
put "Loonies :", l
put "Quarters:", q
put "Dimes :", d
put "Nickels :", n
put "Pennies :", p

if that doesnt work....your loss not mine

Miko99

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

awwww u hurt my feelings....for a second...until i realise its true. and by the way, i dont like your driving so i plan on staying off my lawn! LoL

void

Posted: Wed May 28, 2003 7:49 am Post subject: (No subject)

dont try to get on my good side...you ruined our perfectly fine pointless topic...

Miko99

Posted: Tue Jun 03, 2003 9:53 am Post subject: (No subject)

How do i get this to be continuous. The user will select there choices as much as they want and the price will continue to ad up.

My code so far thanks to void:

code:

var names : array 1 .. 17 of string := init ("Pizza", "Crispy Fries", "Hamburger", "Cheese Burger",
"Chicken Burger", "Submarine", "Salad", "2 Cookies", "Fries", "Pasta",
"Mashed Potatoes", "Baked Potatoes", "Pop", "Chocolate Milk",
"Gatorade/ Powerade", "Water", "Slush Puppy")
var prices : array 1 .. 17 of real := init (2.5, 4, 3, 3.4, 2.4, 5, 3, 1, 2, 2, 1.5,
1, 1, 1.5, 2, 1, 1.35)
var choice : array 1 .. 3 of int
var total : real := 0
var bill : real
var change : real
var f, t, l, q, d, n, p : real := 0
var choice5:string
var count:int:=0
put "Main Dishes Prices"
loop
count:=count+1
for a : 1 .. 7
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
get choice (1)
for a : 8 .. 12
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
put "10-", names (10) : 20, prices (10) : 0 : 2
get choice (2)
for a : 13 .. 17
put a, "-", names (a) : 20, prices (a) : 0 : 2
end for
get choice (3)
total := prices (choice (1)) + prices (choice (2)) + prices (choice (3))
put ("Would you like select 3 more things")
get choice5
exit when (choice5="no")
end loop
for a : 1 .. 3
put names (choice (a)) : 23, prices (choice (a)) : 0 : 2
end for
put "--------------------------"
put "TOTAL:" : 22, total : 0 : 2
put "Enter Bill Being Used:$" ..
get bill

if bill not= 100 or bill not= 50 or bill not= 20 or bill not= 10 or
bill not= 5 then
put "That is not a valid Bill"

elsif bill = 100 or bill = 50 or bill = 20 or bill = 10 or bill = 5 then
end if

change := bill - total
cls
put "Your change is: $", change, " and you will get: "
f := change div 5
change := change - (f * 5)
t := change div 2
change := change - (t * 2)
l := change div 1
change := change - (l * 1)
q := change div .25
change := change - (q * 0.25)
d := change div .1
change := change - (d * 0.1)
n := change div .05
change := change - (n * 0.05)
p := change div .01
change := change - (p * 0.01)

put "Fives :", f
put "Toonies :", t
put "Loonies :", l
put "Quarters:", q
put "Dimes :", d
put "Nickels :", n
put "Pennies :", p

w0lv3rin3

Posted: Tue Jun 03, 2003 8:41 pm Post subject: (No subject)

I'm looking @ this code, what does 21 and 0 : 2 do witin the code

code:

for a : 1 .. 7
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
get choice (1)
for a : 8 .. 12
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for

also here

what does 23, 0 : 2, and in put "TOTAL:" : 22, total : 0 : 2, where u see 22, total : 0 : 2, whats those numbers their for?

code:

for a : 1 .. 3
put names (choice (a)) : 23, prices (choice (a)) : 0 : 2
end for
put "--------------------------"
put "TOTAL:" : 22, total : 0 : 2
put "Enter Bill Being Used:$" ..
get bill

Tony

Posted: Tue Jun 03, 2003 9:15 pm Post subject: (No subject)

alignment...

:number after a string sets the minimum size string has to be and adds spaces to output to match that number, so you can have preaty looking columns...

second :number sets presision of real values (desimal places)

Posted: Wed Jun 04, 2003 1:01 pm Post subject: (No subject)

Well how do i get that code to loop over and over and the total continusely adds up and is displayed at the end, with the exact coins they will get back.

Sponsor Sponsor

krishon

Posted: Wed Jun 04, 2003 1:36 pm Post subject: (No subject)

just put a loop around everything

Miko99

Posted: Mon Jun 09, 2003 8:02 am Post subject: (No subject)

Tried it, and id didn't work.

Andy

Posted: Mon Jun 09, 2003 8:06 am Post subject: (No subject)

turing's mod is screwed up, there is a rounding error

Grey_Wolf

Posted: Mon Jun 09, 2003 3:42 pm Post subject: (No subject)

code:

var names : array 1 .. 17 of string := init ("Pizza", "Crispy Fries", "Hamburger", "Cheese Burger",
"Chicken Burger", "Submarine", "Salad", "2 Cookies", "Fries", "Pasta",
"Mashed Potatoes", "Baked Potatoes", "Pop", "Chocolate Milk",
"Gatorade/ Powerade", "Water", "Slush Puppy")
var prices : array 1 .. 17 of real := init (2.5, 4, 3, 3.4, 2.4, 5, 3, 1, 2, 2, 1.5,
1, 1, 1.5, 2, 1, 1.35)
var choice : array 1 .. 3 of int
var total : real := 0
var bill : real
var change : real
var f, t, l, q, d, n, p : real := 0
var choice5:string
var count:int:=0
put "Main Dishes Prices"
loop
count:=count+1
for a : 1 .. 7
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
get choice (1)
for a : 8 .. 12
put a, "-", names (a) : 21, prices (a) : 0 : 2
end for
put "10-", names (10) : 20, prices (10) : 0 : 2
get choice (2)
for a : 13 .. 17
put a, "-", names (a) : 20, prices (a) : 0 : 2
end for
get choice (3)
total := prices (choice (1)) + prices (choice (2)) + prices (choice (3))
put ("Would you like select 3 more things")
get choice5
exit when (choice5="no")
end loop
for a : 1 .. 3
put names (choice (a)) : 23, prices (choice (a)) : 0 : 2
end for
put "--------------------------"
put "TOTAL:" : 22, total : 0 : 2
put "Enter Bill Being Used:$" ..
get bill

if bill not= 100 or bill not= 50 or bill not= 20 or bill not= 10 or
bill not= 5 then
put "That is not a valid Bill"

elsif bill = 100 or bill = 50 or bill = 20 or bill = 10 or bill = 5 then
end if

change := bill - total
cls
put "Your change is: $", change, " and you will get: "
f := change div 5
change := change - (f * 5)
t := change div 2
change := change - (t * 2)
l := change div 1
change := change - (l * 1)
q := change div .25
change := change - (q * 0.25)
d := change div .1
change := change - (d * 0.1)
n := change div .05
change := change - (n * 0.05)
p := change div .01
change := change - (p * 0.01)

put "Fives :", f
put "Toonies :", t
put "Loonies :", l
put "Quarters:", q
put "Dimes :", d
put "Nickels :", n
put "Pennies :", p

This code should loop it forever although i would suggest asking the user if they wish to continue.

Miko99

Posted: Wed Jun 11, 2003 9:22 am Post subject: (No subject)

That code doesn't keep everything the user selects in memory. I need it to keep everything. so i fi select 6 things, then i get charged for 6 things.

Miko99

Posted: Thu Jun 12, 2003 7:48 am Post subject: (No subject)

can someone please tell me how to get the food program to loop and continuesly add up the prices no matter how much food i select.