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 ?.



corejava-programming: Temperatures

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
Expected input: 120 -1
Expected output: true

corejava x 351
programming x 167
Posted On : 2016-09-02 18:59:01.0
profile Boopalan - anyforum.in Boopalan
3730
up-rate
-3
down-rate

Answers


import java.util.Scanner;

public class Temperatures {
public static void main(String[] args) {
try{
Scanner input=new Scanner(System.in);
System.out.println(icyHot(input.nextInt(),input.nextInt()));
}catch(Exception e){
System.out.println("Invalid input "+e);
}
}
public static boolean icyHot(int temp1,int temp2){
return (temp1>100 && temp2<0) || (temp2>100 && temp1<0);
}
}

Posted On : 2016-09-03 18:19:56
Satisfied : 2 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523187021168
Reply This Thread
up-rate
4
down-rate

import java.util.*;
class temperature
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
float a,b;
a=in.nextFloat();
b=in.nextFloat();

if(a>100 && b<0)
{
System.out.println("true");

}
else if(a>0 && b<100)
{
System.out.println("false");
}
else
{
System.out.println("false");
}
}
}

Posted On : 2016-09-17 11:33:33
Satisfied : 1 Yes  0 No
profile Boopalan - anyforum.in Boopalan
3730
Reply This Thread
up-rate
3
down-rate



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