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

Username:   Password: 
 RegisterRegister   
 true statement
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 2:17 pm   Post subject: true statement

i really need help with how to add up all the selections with the true statement. I am makeing a cash register and i was told to use the true statement thing well i was wondering what it is that i need to put for the true statement to get it to add up all of the selected true statements
Sponsor
Sponsor
Sponsor
sponsor
the_scott_mans




PostPosted: Tue Apr 01, 2003 3:14 pm   Post subject: (No subject)

i am also wondering how i can make it reconize a selection i have it laid out in list form, numbered, and indented. When i use the if statement it does not reconize it.
Tony




PostPosted: Tue Apr 01, 2003 5:00 pm   Post subject: (No subject)

you're probably refering to boolean variable. It is used like a flag to mark stuff. For example:

code:

var total:int %counter
var price:int %variable
var word:string
var tax:boolean %true/false flag for tax

loop
put "enter price"
get price
total := total + price

exit when price =0
end loop

put "add tax? y/n"
get word

if word="y" then
tax := true
else
tax := false
end if

%now you can use that "tax" variable to check what the user selected from before

if tax=true then
put total+total*0.15
else
put total
end if
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
the_scott_mans




PostPosted: Tue Apr 01, 2003 5:44 pm   Post subject: (No subject)

thanks that helps but how does it work with a list.

like all the items are numbered and you select the numbers then press done and it adds the tax and price of each selection.
Tony




PostPosted: Tue Apr 01, 2003 5:52 pm   Post subject: (No subject)

make another array of boolean type with a coresponding numbers.

such as

tax(1) would keep true/false value about item(1)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
the_scott_mans




PostPosted: Tue Apr 01, 2003 6:18 pm   Post subject: (No subject)

so would i just put

if choice = "1" then
choice := true
else
choice := false
end if

if choice = "2" then
choice := true
else
choice := false
end if

etc.

and then

if choice = true then
put total+total*0.15
end if

or how would i get the computer to record all the prices then add them up
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  [ 6 Posts ]
Jump to:   


Style:  
Search: