Q:

Write a Ruby program to check two temperatures and return true if one is less than 0 and the other is greater than 100

0

Write a Ruby program to check two temperatures and return true if one is less than 0 and the other is greater than 100. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def temp(temp1, temp2)
    return ( temp1 < 0 && temp2 > 100 ) || ( temp1 > 100 && temp2 < 0 );
end
print temp(110, -1),"\n"
print temp(-1, 110),"\n"
print temp(2, 120)

Output:

true
true
false

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now