Computer Science Canada need help for no values |
Author: | person [ Thu Jan 13, 2005 4:09 pm ] |
Post subject: | need help for no values |
When i run this code, there is obviously going to be 2 variables that dont have a value. How do i tell the computer that to make the variables with no values have a value equal to 40. Here's my code. var as : int := Rand.Int (1, 100) var s1, s2, s3, s4, s5 : int if as >= 1 and as <= 50 then s1 := 10 elsif as >= 51 and as <= 75 then s2 := 10 elsif as >= 76 and as <= 89 then s3 := 10 elsif as >= 90 and as <= 96 then s4 := 10 else s5 := 10 end if if (as >= 51 and as <= 63) or (as >= 76 and as <= 82) or (as = 90 or as = 91) or as = 97 then s1 := 20 elsif (as >= 1 and as <= 25) or (as >= 83 and as <= 86) or (as = 92 or as = 93) or as = 98 then s2 := 20 elsif (as >= 26 and as <= 39) or (as >= 64 and as <= 70) or (as = 94 or as = 95) or as = 99 then s3 := 20 elsif (as >= 40 and as <= 47) or (as = 87 or as = 88) or (as >= 71 and as <= 73) or as = 100 then s4 := 20 else s5 := 20 end if if (as >= 51 and as <= 57) or (as >= 76 and as <= 79) or as = 90 then s1 := 30 elsif (as >= 1 and as <= 13) or (as >= 83 and as <= 85) or as = 92 then s2 := 30 elsif (as >= 26 and as <= 33) or (as >= 64 and as <= 67) or as = 93 then s3 := 30 elsif (as >= 40 and as <= 43) or as = 87 or as >= 71 then s4 := 30 else s5 := 30 end if |
Author: | Neo [ Thu Jan 13, 2005 4:39 pm ] | ||
Post subject: | Re: need help for no values | ||
person wrote: When i run this code, there is obviously going to be 2 variables that dont have a value. How do i tell the computer that to make the variables with no values have a value equal to 40. Here's my code.
Whuh? ![]() You want a variable to have a value of 40?
![]() Use code takes to avoid having bits of ur code turn into emoticons. |
Author: | Tony [ Thu Jan 13, 2005 4:48 pm ] |
Post subject: | |
are you asking for a suspension ? |
Author: | Cervantes [ Thu Jan 13, 2005 5:05 pm ] | ||
Post subject: | Re: need help for no values | ||
Neo wrote: person wrote: When i run this code, there is obviously going to be 2 variables that dont have a value. How do i tell the computer that to make the variables with no values have a value equal to 40. Here's my code.
Whuh? ![]() You want a variable to have a value of 40?
![]() Use code takes to avoid having bits of ur code turn into emoticons. He's asking how to check if a variable has no value. Look at his program, everything is based on the value of 'as'. In this case, person, what you could do is, when you declare those five variables, give them all a value of 40. When your program runs, some of them will be changed. The ones that aren't changed would be the ones that would have had no value if you don't assign them a value when you declare them. -Cervantes |