Computer Science Canada

help with cashier type program...

Author:  nick48 [ Thu Feb 26, 2009 1:57 pm ]
Post subject:  help with cashier type program...

i am expirencing diffculties with my program, code for download.

what i am trying to do is to get the program to output combo not valid when user inputs a number greater then 5, when i do it crashes any help?

Author:  Razgriz [ Thu Feb 26, 2009 2:20 pm ]
Post subject:  RE:help with cashier type program...

Go to school :>

They teach you it on like... the fourth day of ICS3M


But...

Is your computer a hunk of scrap metal?

Maybe you just need a better computer.

Author:  Insectoid [ Thu Feb 26, 2009 3:05 pm ]
Post subject:  RE:help with cashier type program...

Razgriz, that is not the answer expected of compsci.ca members. Please post constructively or not at all.

Author:  nick48 [ Thu Feb 26, 2009 3:13 pm ]
Post subject:  RE:help with cashier type program...

im in grade 10, so techincally i am in school before u talk, anyways can anyone help?

Author:  saltpro15 [ Thu Feb 26, 2009 3:41 pm ]
Post subject:  Re: help with cashier type program...

fixed Very Happy you put your end if in the wrong place, and you declared if payment < TotalCost twice

Turing:

% (c) nick moscioni & justin sciarrino

var GST, PST, totalCost, payment, cost1, choice, sex : real

var counter, cost2 : int

var cost : int

put "Here are the specials for the day:"

put "Combo 1: juice, muffin, coffee,"

put "Combo 2: cereal, toast, milk"

put "Combo 3: egg, toast, coffee"

put "Combo 3: banana, granola"

put "Combo 5: grapefruit, bacon, eggs, coffee, french toast"

put "Choose between each Combo(Choose number)"



get choice

if choice = 1 then

    put "It's $5.00"

    sex := 5

elsif choice = 2 then

    put "It's $15.00"

    sex := 15

elsif choice = 3 then

    put "It's $10.00"

    sex := 10

elsif choice = 4 then

    put "It's $7.00"

    sex := 7

elsif choice = 5 then

    put "It's $20.00"

    sex := 20

end if

GST := sex * 0.05

PST := sex * 0.08

totalCost := sex + GST + PST

if choice >5 then

put "Combo not valid"

end if
put "the total cost is:"

put totalCost

put "how much money are you going to give"

get payment

cost1 := payment - totalCost

put "your change is:"

put cost1

if payment >= totalCost then

    drawfilloval (320, 200, 50, 50, yellow)

    drawfilloval (300, 220, 5, 5, black)

    drawfilloval (340, 220, 5, 5, black)

    drawline (320, 220, 320, 190, black)

    drawarc (320, 170, 10, 10, 180, 369, black)

   

end if



if payment < totalCost then

    drawfilloval (320, 200, 50, 50, yellow)

    drawfilloval (300, 220, 5, 5, black)

    drawfilloval (340, 220, 5, 5, black)

    drawline (320, 220, 320, 190, black)

    drawarc (320, 170, 10, 10, 180, 169, black)



    counter := 0

    loop

        counter := counter + 1

        delay (200)

        put "you cannot purchase item" ..

        exit when counter = 1

    end loop

end if



locate (25, 80)

put " (C)Nick and Justin"



enjoy gr10 CS, I just finished it Wink

Author:  nick48 [ Thu Feb 26, 2009 3:50 pm ]
Post subject:  RE:help with cashier type program...

wow thanks man Wink


: