java Write a program that prints messages for weather The pr

java Write a program that prints messages for weather. The program will get Fahrenheit degree from user input and print out following messages on the screen: If temperature in Fahrenheit is over 100, print out message “Give us Ice! we are almost dead!!”. If temperature in Fahrenheit is over 95, print out message “It\'s too hot!”. If temperature in Fahrenheit is over 86, print out message “It\'s still hot!”. If temperature in Fahrenheit is over 77, print out message “It\'s O.K…!”. If temperature in Fahrenheit is over 68, print out message “It\'s good to do exercise!”. If temperature in Fahrenheit is over 50, print out message “ It\'scool !”. If temperature in Fahrenheit is over 32, print out message “It\'s chilly!”. If temperature in Fahrenheit is less than 32, print out message “It’s cold!”. use if... else if... else structure what we studied in the class.

Solution

//program is given below

import java.util.Scanner;
//scanner class is used to read user input
public class HelloWorld{

public static void main(String []args){

Scanner scanner = new Scanner(System.in);
//prompt and accept input from user
System.out.print(\"Enter temperature in fahrenheit: \");
double temp = scanner.nextInt();

//using if else print message according to temperature
if(temp>100)
System.out.println(\"Give us Ice! we are almost dead!!\");
else if(temp>95&&temp<=100)
System.out.println(\"It\'s too hot!\");
else if(temp>86&&temp<=95)
System.out.println(\"It\'s still hot!\");
else if(temp>77&&temp<=86)
System.out.println(\"It\'s O.K...!\");
else if(temp>68&&temp<=77)
System.out.println(\"It\'s good to do exercise!\");
else if(temp>50&&temp<=68)
System.out.println(\"It\'s cool !\");
else if(temp>=32&&temp<=50)
System.out.println(\"It\'s chilly!\");
else if(temp<32)
System.out.println(\"It\'s cold!\");

}
}

/*Output

Enter temperature in fahrenheit: 42 It\'s chilly!   

java Write a program that prints messages for weather. The program will get Fahrenheit degree from user input and print out following messages on the screen: If

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site