In: Computer Science
Implement Java source code for a class called Temperature that
does the following:
a. Prompts the user to input a temperature
b. Prints “Too Hot!” when the input temperature is above 75
c. Prints “Too Cold!” when the input temperature is below 40
d. Prints “Just Right!” when the input temperature is 40 to
75
e. Be precise, include comments, prologue, etc. if needed.
Hello, I am putting java code as your requirement with comments. please go through it and if you have any problem, comment here. also If you are fine with the answer, give me a like.
import java.util.Scanner;
public class Temperature
{
public static void main(String[] args) {
// For Taking input from user
Scanner scn = new
Scanner(System.in);
System.out.println("Enter
Temperature:");
// Temperature as integer
input
int temp = scn.nextInt();
// If Temperature is too high means
>75
if(temp > 75){
System.out.println("Too Hot!");
}
// If Temperature is too cool means <40
else if(temp < 40){
System.out.println("Too Cold!");
}
// otherwise this will execute which means Temperature
between 40 and 75
else{
System.out.println("Just Right!");
}
}
}
Thank you.