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

Username:   Password: 
 RegisterRegister   
 assigned values are the wrong type
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
goroyoshi




PostPosted: Wed Apr 06, 2011 6:27 pm   Post subject: assigned values are the wrong type

Turing:

var a, b, c, d, e : nat := 0
var choose, times : int
var angle : array 1 .. 5 of nat

put "how many times"

get times

for x : 1 .. times
    randint (choose, 1, 5)
    if choose = 1 then
        a += 1
    elsif choose = 2 then
        b += 1
    elsif choose = 3 then
        c += 1
    elsif choose = 4 then
        d += 1
    elsif choose = 5 then
        e += 1
    end if
end for

angle (1) := (360 / times) * a % these lines glitch
angle (2) := (360 / times) * b + angle (1)
angle (3) := (360 / times) * c + angle (2)
angle (4) := (360 / times) * d + angle (3)
angle (5) := (360 / times) * e + angle (4) %till here

put "a: ", a
put "b: ", b
put "c: ", c
put "d: ", d
put "e: ", e

drawfillarc (maxx div 2, maxy div 2, 100, 100, angle (1), angle (2), 1)
drawfillarc (maxx div 2, maxy div 2, 100, 100, angle (2), angle (3), 2)
drawfillarc (maxx div 2, maxy div 2, 100, 100, angle (3), angle (4), 3)
drawfillarc (maxx div 2, maxy div 2, 100, 100, angle (4), angle (5), 4)
drawfillarc (maxx div 2, maxy div 2, 100, 100, angle (5), 360, 5)


whenever i try to run this it says assigned value is the wrong type to the multipliers of my angles (a, b, c, d, e, angle (1), angle (2), angle (3), angle (4))
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Apr 06, 2011 6:39 pm   Post subject: RE:assigned values are the wrong type

Yes, the expression result and the variable are of different types.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
goroyoshi




PostPosted: Wed Apr 06, 2011 6:47 pm   Post subject: RE:assigned values are the wrong type

it happens even if both are integers
fixed it with round and real numbers
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  [ 3 Posts ]
Jump to:   


Style:  
Search: