Computer Science Canada i dont know why this is coming up as an error |
Author: | Genisis [ Fri Oct 14, 2005 8:09 am ] |
Post subject: | i dont know why this is coming up as an error |
will someone help me with this? Code: colorback (brightpurple) cls var nam : string var age : int var wag : real var tim : real var pay : int loop put "Hello what is your name?" get nam delay (1000) cls put "How old are you?" get age delay (1000) cls put "How many hours did you work this week?" get tim delay (1000) cls if tim >= 50 then put "You work to much" end if put "How many dollars do you make per hour?" get wag delay (1000) cls pay := wag * tim put nam, " you will be getting a pay of ", pay, "$ this pay check" put "For the ", tim, " hours that you have worked" put "This program will restart in 10 seconds" end loop |
Author: | ZeroPaladn [ Fri Oct 14, 2005 8:53 am ] | ||
Post subject: | |||
this is probably for school, eh? dont worry, i helped you out. yor vaiables wag and tim are set as real numbers. just reser the varibale type to integers, and it runs. here, ill repost the code for ya.
|
Author: | jamonathin [ Fri Oct 14, 2005 10:41 am ] | ||||
Post subject: | |||||
The reason why you have to change it from ' : real ' to ' : int ' is because an integer (int) has to be a whole number. So, since an int has to be a whole number then this should work, right?
My theory is, that the programmers of Turing were too lazy to check when an integer variable is added by (or made value of) a real number, if the number is whole or not. So instead what you have to do is round the number first.
'round ()' converts a real number into an integer acceptable number. Doesn't make sense sometimes but neither do a lot of things. ** So, 'round ()' also works for other commands that require integer values. Such as any of the 'Draw' commands. You CAN use real numbers in the command, you just have to use 'round (real)' instead of just putting your 'real' variable. ** I hope this made sense |
Author: | [Gandalf] [ Fri Oct 14, 2005 3:09 pm ] |
Post subject: | |
Oh, and use more meaningful variable names. This isn't BASIC where you are limited on variable name length, and I think even that allowed more than 3 letters . |
Author: | Finaltank [ Fri Oct 14, 2005 3:29 pm ] |
Post subject: | |
To fix this turn your 'int's to 'real's Pink is a hellish background |
Author: | jamonathin [ Fri Oct 14, 2005 7:56 pm ] |
Post subject: | |
Woah woah, dont diss the pink. Just because you joined compsci on my birthday doesn't mean you can knock on a pink background. P.I.N.K. -> Pwnage In New Kolor |
Author: | Genisis [ Fri Oct 14, 2005 9:50 pm ] |
Post subject: | |
thanks guys i didnt see that intell i posted this and then my friend help me out to thanks for ur help too |