AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



programming-basics: Check the temperature


Given two temperatures, print ´true´ if one is less than 0 and the other is greater than 100. Else print ´false´

icyHot(120, -1)--> true

icyHot(2, 120) --> false

Sample input:

120 -1

Sample output:

true


programming x 167
basics x 170
Posted On : 2017-02-01 17:40:08.0
profile Raksha - anyforum.in Raksha
2510
up-rate
-3
down-rate

Answers


public static boolean icyHot(int a, int b){
return ((a<0 && b>100) || (b<0 && a>100))?true:false;
}


Example:
--------------------------------------
public class Temperature {
public static void main(String[] args) {
System.out.println(icyHot(2,120));
}

public static boolean icyHot(int a, int b){
return ((a<0 && b>100) || (b<0 && a>100))?true:false;
}

}

Posted On : 2017-02-02 23:49:39
Satisfied : 1 Yes  2 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523187021414
Reply This Thread
up-rate
3
down-rate
Comments
For the input 120 -1 the output is displaying as false. Please fix the error
profile Raksha - anyforum.in Raksha
25  1  0
Posted On :2017-02-05 10:58:15.0
Leave a Comment
Hi Raksha,
I tested the above code, It´s returning true which is correct result for 120, -1
profile Rishi Kumar - anyforum.in Rishi Kumar
523  1870  21414
Posted On :2017-02-07 00:04:15.0
Leave a Comment
Hi Prince,
I checked it again, It´s not returning the correct result for 120, -1.
profile Raksha - anyforum.in Raksha
25  1  0
Posted On :2017-02-11 20:51:44.0
Leave a Comment



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in