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

Username:   Password: 
 RegisterRegister   
 Help with Rounding
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Zeppelin




PostPosted: Fri May 23, 2008 8:15 pm   Post subject: Help with Rounding

For some reason I can't round numbers. I looked in the Turing help file and it seems I'm doing it correctly but I constantly get an error that reads "b is not a procedure and hence cannot be called" I tried the same thing with a number like 1.5 and got the same error. Judging by this code could you tell me what I'm doing wrong (Note it's not done yet so there are a bunch of unused veriables and unfinished code)?

code:

var Angle, Angle2, CoAx, Line, XBullet, YBullet : int
var c, b : real


CoAx := 25

%Angle := Rand.Int (0, 89)
Angle := 60
%Line := Rand.Int (1, CoAx)
Line := 12

if Angle < 90 then
b := Line * cosd (Angle)
c := Line * cosd (90 - Angle)

round (b)
round (c)
end if

%elsif Angle >= 90 and < 180 then
%Angle2 := Angle - 90

put b
put c
Sponsor
Sponsor
Sponsor
sponsor
gitoxa




PostPosted: Fri May 23, 2008 8:18 pm   Post subject: RE:Help with Rounding

round, ceil, and floor are functions. Functions return a value. Typing in

code:
round (b)


is the same as typing in

code:
12


You have to use the value in some way. Either by assigning it, using it in a decision structure, or even using it in another function.
Zeppelin




PostPosted: Fri May 23, 2008 9:12 pm   Post subject: Re: Help with Rounding

Thanks for the help. The program works now.
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: