Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 What does this error message mean and how can I fix it?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
t2xplosions




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: