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

Username:   Password: 
 RegisterRegister   
 How to add up selected choices
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
the_scott_mans




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
yuethomas




PostPosted: Tue Apr 01, 2003 8:53 pm   Post subject: (No 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
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 1  [ 2 Posts ]
Jump to:   


Style:  
Search: