Computer Science Canada Help Turing Functions Assignment |
Author: | JumpingLimaBean [ Thu Apr 28, 2011 5:29 pm ] |
Post subject: | Help Turing Functions Assignment |
So i was absent from school today, and it turns out my class learnt functions. I have to do the following in one program: Write a program that includes the following functions: 1. average - send two real numbers as parameters, and return the average of the two numbers 2. isOdd - send an integer as a parameter, and return true if the number is odd, and false otherwise. 3. distance - send two pairs of x and y coordinates as parameters, and return the distance between the two points. 4. getInteger - send a string as a parameter. The string should represent the message printed for the user. The method will print the message to the user, and then get the user's input. The method should return the integer if it is valid input, or keep requesting new input if the user does not provide valid input. This makes no sense *<* --- Also i have no idea what a parameter is |
Author: | Tony [ Thu Apr 28, 2011 5:36 pm ] |
Post subject: | RE:Help Turing Functions Assignment |
What makes no sense? We have tutorials that you can use to catch up on particular material. A function is just a way to encapsulate a block of code so that it can be easily re-used. |
Author: | Raknarg [ Thu Apr 28, 2011 6:10 pm ] |
Post subject: | Re: Help Turing Functions Assignment |
http://compsci.ca/v3/viewtopic.php?t=14665 If you've ever done procedures, they're very similar. |
Author: | JumpingLimaBean [ Thu Apr 28, 2011 8:52 pm ] |
Post subject: | RE:Help Turing Functions Assignment |
Ya we did procedures yesterday |
Author: | JumpingLimaBean [ Thu Apr 28, 2011 8:59 pm ] |
Post subject: | RE:Help Turing Functions Assignment |
Okay i checked out Parameters but wtf. i need to write this in procedure form. I have to do this: Write a program that includes the following functions: 1. average ? send two real numbers as parameters, and return the average of the two numbers i already created this- var num1 : real var num2 : real var averages : real procedure average put "Enter a real number:".. get num1 put "Enter a 2nd real number:".. get num2 averages := (num1 + num2) / 2 put " The average of them is:",averages end average average How do i incorporate parameters into the code |
Author: | Tony [ Thu Apr 28, 2011 9:02 pm ] | ||
Post subject: | RE:Help Turing Functions Assignment | ||
|
Author: | JumpingLimaBean [ Thu Apr 28, 2011 10:48 pm ] |
Post subject: | RE:Help Turing Functions Assignment |
ya tony, but i still dont get how to use that for my code |
Author: | Tony [ Fri Apr 29, 2011 2:06 am ] |
Post subject: | RE:Help Turing Functions Assignment |
What part of the example are you having problems with? |
Author: | Raknarg [ Fri Apr 29, 2011 1:50 pm ] | ||
Post subject: | RE:Help Turing Functions Assignment | ||
You incorporate them the same way Tony did.
You can do stuff with those parameters. |