005-002-002
If-Else Statement: Temperature Comfort
Easy
Problem Description
If-Else Statement: Temperature Comfort
Learning Objective: Make binary choice with if-else statement
In this problem, you will create a program that compares an input temperature against the threshold of 25 degrees and displays either "It's hot" or "It's cool" to standard output.
Create a program that inputs a temperature and displays "hot" for 25 or above, "cool" for under 25. Use an if-else statement to always display exactly one of the two results.
Input
Line 1: Temperature (integer)
Output
For 25+:
Current temperature: [temp] degrees
It's hot
For under 25:
Current temperature: [temp] degrees
It's cool
Examples
Example 1: 30 degrees (hot)
Input:
30
Output:
Current temperature: 30 degrees
It's hot
Example 2: 20 degrees (cool)
Input:
20
Output:
Current temperature: 20 degrees
It's cool
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
35
Expected Output:
Current temperature: 35 °C It's hot
Normal case
Input:
10
Expected Output:
Current temperature: 10 °C It's cool
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 10 free executions remaining
