Question:
Develop a program to get the temperature and print the following status
according to the given temperature by using else if ladder statement.
1. T<=0 "Its very very cold".
2.0 < I<= 10 "Its cold".
3. 10 <T <=20 "Its cool out".
4. 20 <I<=30 "Its warm".
5. T>30 "Its hot".
Answers
Program :
import java.util.*;
public class MyClass
{
public static void main(String args[])
{
Scanner Sc = new Scanner(System.in);
int T;
System.out.print("Enter Temperature : ");
T = Sc.nextInt();
if(T <= 0)
{
System.out.print("Its very very cold.");
}
else if(T > 0 && T <= 10 )
{
System.out.print("Its cold.");
}
else if(T > 10 && T <= 20)
{
System.out.print("Its cool out.");
}
else if(T > 20 && T <= 30)
{
System.out.print("Its warm.");
}
else
{
System.out.print("Its hot.");
}
}
}
Answer:
https://www.scribd.com/document/338410769/90-48173-FINALmaterial-C-and-DS-Course-Handout-22-08-15