Computer Science Canada

Subracting a varaible from an other varaible

Author:  david92ng [ Fri Oct 26, 2007 7:46 pm ]
Post subject:  Subracting a varaible from an other varaible

Hey,

lets say we have a code like this:

code:
var money : real
var bet :real


so..... I declared it but I don't know how to subtract the bet from the ammout of money.
If you havnt figured it out yet, im makeing a card game.

Im looking for a code something like this:

code:
money := money - bet


but everyone here knows this wont work... LOL but you get my idea rite?

Any suggestions? or is there a better way of doing this?
Thanks, asap is good

Author:  david92ng [ Fri Oct 26, 2007 7:47 pm ]
Post subject:  Re: Subracting a varaible from an other varaible

ummm... yea... im kinda new to turing

Author:  SNIPERDUDE [ Fri Oct 26, 2007 8:56 pm ]
Post subject:  Re: Subracting a varaible from an other varaible

Ummm, no. I don't get what you mean, you will have to be more specific...

Author:  rdrake [ Fri Oct 26, 2007 9:26 pm ]
Post subject:  RE:Subracting a varaible from an other varaible

code:
money -= bet

...?

Author:  CodeMonkey2000 [ Fri Oct 26, 2007 9:27 pm ]
Post subject:  Re: Subracting a varaible from an other varaible

david92ng @ Fri Oct 26, 2007 7:46 pm wrote:

code:
money := money - bet

but everyone here knows this wont work... LOL but you get my idea rite?


That code will work. But money and bet need to be assigned a value first.

Author:  Nick [ Fri Oct 26, 2007 9:38 pm ]
Post subject:  RE:Subracting a varaible from an other varaible

well ur code will work but there is a better way to do it and rdrake has got it

the money-=bet will act as tho u said money:=money - bet also there is += which is money:=money + bet and also ~= which is not = of money:= money not= bet (usually used for boolean varibles

but what u are looking for is the -= (and possibly += if they win the hand) this is how it will look

Turing:
var money:real
var bet:real

%assign bet and money to a value
money:=1000
put "How much will you bet?"
get bet

money-=bet

%some code here

if win then
   money+=bet
end if

Author:  david92ng [ Fri Oct 26, 2007 10:18 pm ]
Post subject:  Re: Subracting a varaible from an other varaible

ah thanks, thats exactly what im looking for. like my old code didnt subtract as the output. i think i know why now. thanks for all your help guys.


: