Computer Science Canada

How to add up selected choices

Author:  the_scott_mans [ Tue Apr 01, 2003 8:43 pm ]
Post subject:  How to add up selected choices

I was wondering on how to add up selected stuff.

Ex.
A list of items

1. Xbox
2.Gamecube
3.PS2
4.PC

say the user selects 1, 3 & 4 well i want it to add up just those. By adding i mean PRICES

Author:  yuethomas [ Tue Apr 01, 2003 8:53 pm ]
Post subject: 

If I make any grammar errors, please correct it. Very Happy (it's been a year and half since I've done Turing)

code:
// variable declarations omitted
XBoxprice := 299
GameCubeprice := 199
PS2price := 259
PCprice := 799

loop
    put "Please input selection: "
    get selectitem
    if selectitem = 1 then price += XBoxprice
    elsif selectitem = 2 then price += GameCubeprice
    elsif selectitem = 3 then price += PS2price
    elsif selectitem = 4 then price += PCprice
    else break // nor this
end loop
put "Total price: ", price


: