
-----------------------------------
alex12342011
Fri May 14, 2010 10:38 pm

&quot;Elsif&quot; All of them can be true, how do you diffrentiate?
-----------------------------------
What is it you are trying to achieve?

I am trying to create a program that asks the user to enter a temperature in degrees Celsius.  Using an if-then-else structure to print a message based on the following ranges:
	below  18		very cold
	 18 or below 0	cold
	0			freezing point of water
	above 0 to 10	very cool
	11 to 20		moderate
	21 to 30		warm
	31 to 40		hot
	41 to 99		extremely hot
	100			boiling point of water     


What is the problem you are having?


But... my program just tells me "very cool" for everything over 0.



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



var t : real
var reply : string (1)

put "This program will describe the temperature of the environment."
locate (3, 8)
put "Please press any key to continue."
getch (reply)
cls


put "Please enter the temperature in degrees celsius."
get t

if t < -18 then
put "Very cold!"
elsif t < 0 then
put "Cold"
elsif t = 0 then
put "Freezing point of water"
elsif t > 0 or t = 10 then
put "Very cool"
elsif t > 11 or t = 11 then
put "Moderate"
elsif t > 21 or t = 21 then
put "Warm"
elsif t > 31 or t = 31 then
put "Hot"
elsif t > 41 or t = 41 then
put "Extremely hot!"
elsif t = 100 then
put "Boiling point of water"

end if




Please specify what version of Turing you are using
I am using version 4.05 of turing.


BTW I've read the tutorial on the if statements, maybe I missed something? Thanks for any replies in advance, appreciate the help.

-----------------------------------
TheGuardian001
Fri May 14, 2010 10:57 pm

Re: &quot;Elsif&quot; All of them can be true, how do you diffrentiate?
-----------------------------------
Read you statements out as if they were a sentence. For example, your first condition with an or, as a sentance:
or. This means that if either condition is true (doesn't have to be both), the entire thing is true. You probably want to use and, since you want both to be true. So even if temperature isn't 10, so long as temperature is > 0, the entire thing is considered true.

Oh, and you shouldn't be using =. That's a definite value, not a range.

-----------------------------------
alex12342011
Fri May 14, 2010 11:31 pm

Re: &quot;Elsif&quot; All of them can be true, how do you diffrentiate?
-----------------------------------
How do you input ranges? I'm new at this so pardon me.
-thanks

-----------------------------------
Tony
Sat May 15, 2010 12:29 am

RE:&quot;Elsif&quot; All of them can be true, how do you diffrentiate?
-----------------------------------
You describe a range with a lower bound and an upper bound.
true for any number.

-----------------------------------
alex12342011
Sat May 15, 2010 8:52 pm

Re: &quot;Elsif&quot; All of them can be true, how do you diffrentiate?
-----------------------------------
Sweet! I got it, thanks for the help both of you guys.
