Computer Science Canada

What does this error message mean and how can I fix it?

Author:  t2xplosions [ Sun Dec 11, 2016 2:12 am ]
Post subject:  What does this error message mean and how can I fix it?

What is it you are trying to achieve?
The program is meant to get 15 heights and output which ones are above and below the average for the group.

What is the problem you are having?
Error message "Assigned value is the wrong type"

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
The problem is at
average:=(average+heights(count))/count

Turing:


 var heights : array 1..15 of int
    var average : int :=0
   
        for count : 1..15
            put "Give me height number ", count
            get heights(count)
            average:=(average+heights(count))/count
        end for
       
        cls
       
        for count : 1..15
            put " "
            if heights(count)>=average then put heights(count), "is an above average height."
                else put heights(count), "is a below average height."
            end if
        end for




Please specify what version of Turing you are using
4.1.1

Author:  Insectoid [ Sun Dec 11, 2016 9:21 am ]
Post subject:  RE:What does this error message mean and how can I fix it?

Your average variable is an integer. Division returns a value of type real. You cannot assign a real value to an integer. It just can't be done.

You can either change average to a real, or change your division to something else.


: