
-----------------------------------
MrGuild125
Mon Feb 27, 2012 7:08 pm

ProcedureHELP!!!
-----------------------------------
What is it you are trying to achieve?
I am trying to make this procedure but it always errors on me!!! 


What is the problem you are having?
var Celsius, Fahrenheit : int
const Celsius_to_Fahrenheit := 9/5 + 32

procedure p_input 
    put "Enter the temperature in Celsius:"
    get Celsius 
end p_input 

procedure p_process 
    Fahrenheit := Celsius * Celsius_to_Fahrenheit
    put "" 
end p_process 

procedure p_output
    put "Farenheit value is:"
    put Fahrenheit
end p_output 

p_input 
p_process
p_output  

after  Fahrenheit := Celsius * Celsius_to_Fahrenheit 
it errors on Celsius_to_Fahrenheit or ANYTHING I put there :'(



Describe what you have tried to solve this problem
I have tried to change the value and the * sign to + or - 


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




var Celsius, Fahrenheit : int
const Celsius_to_Fahrenheit := 9/5 + 32

procedure p_input 
    put "Enter the temperature in Celsius:"
    get Celsius 
end p_input 

procedure p_process 
    Fahrenheit := Celsius * Celsius_to_Fahrenheit
    put "" 
end p_process 

procedure p_output
    put "Farenheit value is:"
    put Fahrenheit
end p_output 

p_input 
p_process
p_output  



Please specify what version of Turing you are using
4.1.1

-----------------------------------
crossley7
Mon Feb 27, 2012 7:13 pm

RE:ProcedureHELP!!!
-----------------------------------
well, first of all look at your constant.  It is just a value = 9/5+32 = 169/5 rather than a formula which is what you need.  Also, your variables are integers but in the majority of cases are supposed to be reals.  I think that should be enough to help you find your problems.  The procedures themselves are not your issue

-----------------------------------
MrGuild125
Mon Feb 27, 2012 7:23 pm

RE:ProcedureHELP!!!
-----------------------------------
It was the variables :P they needed to be reals like u said :D TY TY :)

-----------------------------------
MrGuild125
Mon Feb 27, 2012 7:25 pm

RE:ProcedureHELP!!!
-----------------------------------
Would you like to maybe explain why it needs to be a real? if not thats fine I would just like the knowledge so I dont run into this again :)

-----------------------------------
smool
Mon Feb 27, 2012 9:00 pm

RE:ProcedureHELP!!!
-----------------------------------
an integer value is just whole numbers, no decimal points, where as a real value has decimal points. So when multiplying the Celcius by (9/5), it gives you a number with decimal points, which is why you need a real value.

-----------------------------------
crossley7
Mon Feb 27, 2012 9:24 pm

RE:ProcedureHELP!!!
-----------------------------------
In general for turing number types you have ints and reals.  The difference between the 2 is as follows.

int - as it says, it is an integer.  This means positive or negative values that contain 0 decimal places.
eg. -1,5,20,-86 etc.

real - also self explanatory, a real number.  This is any positive or negative number that has no imaginary components (if you aren't in grade 11 yet, then any number that you have used in math class)

eg. 5.5, 3.3333, 8.12345 etc

Keep in mind what types of values you want to have in your programming which type of variable you use.  Celsius and Fahrenheit are values that can be non integer and so must be defined as real.  Look up the different types for variables that you can use so you can choose the best type for your purposes in your programs.

-----------------------------------
MrGuild125
Mon Feb 27, 2012 10:55 pm

RE:ProcedureHELP!!!
-----------------------------------
Yea I just hit grade 11 and am in computer programming, thanks for the help :) I'm 3 chapters ahead so my peers cant help and the teacher is busy helping others move past var/cont type : int :P and ya I knew ints and reals I was just being an idiot and didnt realize but thanks for pointing that out for me! :D

-----------------------------------
MrGuild125
Mon Feb 27, 2012 10:58 pm

RE:ProcedureHELP!!!
-----------------------------------
I have 1 last question you may be able to help with. In this program I need to say 

if (sum >10 and < 19) then 
put "your number is between 10 and 19"
end if 

How can I do this with the knowledge of , procedures, variables, const, and all the small stuff between that?

-----------------------------------
crossley7
Mon Feb 27, 2012 11:06 pm

RE:ProcedureHELP!!!
-----------------------------------
basically as you just stated.  Just remember both sides of every condition need a value and check if you want =.  No need for constants, procedures, etc.

A single variable that you get (again make sure you have the correct type) and then an if statement checking if it is in a range.

-----------------------------------
MrGuild125
Mon Feb 27, 2012 11:10 pm

RE:ProcedureHELP!!!
-----------------------------------
But... sum > 10 and < 19 errors on me? so I thought it had to be done a different way?

-----------------------------------
crossley7
Mon Feb 27, 2012 11:22 pm

RE:ProcedureHELP!!!
-----------------------------------
like I said both sides of the condition need a value.

condition 1 there is   sum > 10
condition 2 there is   < 19

you just have to learn to think as the computer thinks.  the and is the start of another condition.  or does the same thing.

-----------------------------------
MrGuild125
Mon Feb 27, 2012 11:28 pm

RE:ProcedureHELP!!!
-----------------------------------
Can this be done all in one if statement? because It needs to be all in 1 if statement :/ 

[code] 
var value, sum, x : int
var category : string 

procedure p_input 
    put "Please enter a value."
    get value
end p_input 

procedure p_process
    sum := value * value
    
    if (sum 