Computer Science Canada

using real numbers in case?

Author:  bvbjules13 [ Sat Jan 12, 2013 5:14 pm ]
Post subject:  using real numbers in case?

What is it you are trying to achieve?
i am trying to use a decimal (or real number) in a case statement

What is the problem you are having?
keep getting message of "Bad type for case expression"

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:

%trying to make sure the random integer is able to be divided by 50
houseX (i) := Rand.Int (100, 750)
check := houseX (i)/50
        loop
            case check of
                label 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 :
                    exit
                label :
                    houseX (i) := Rand.Int (100, 750)
            end case
        end loop



Please specify what version of Turing you are using
4.1

Author:  Insectoid [ Sat Jan 12, 2013 5:34 pm ]
Post subject:  RE:using real numbers in case?

There's a much, much easier way to do this. Look up the 'mod' operator.


Also, if your case statement only has one case (plus the default case), you probably shouldn't be using a case statement.


: