004-002-002
Else If: Temperature Level Determination
Easy
Problem Description
Else If: Temperature Level Determination
Learning Objective: Perform staged classification with else if and evaluate multiple conditions in order
In this problem, you will create a program that reads an integer temperature using Scanner, classifies it into one of 5 comfort levels using else if statements, and displays the result to standard output.
Determine comfort level from temperature. Display 5-level comfort message based on temperature.
Input
Line 1: Temperature (integer)
Output
Temperature: [temp] degrees
Level: [Extreme heat/Hot/Comfortable/Cold/Freezing]
```java
## Criteria
- 35 or higher: "Extreme heat"
- 25 to 34: "Hot"
- 15 to 24: "Comfortable"
- 5 to 14: "Cold"
- Below 5: "Freezing"
## Examples
### Example 1: Extreme Heat Level
Input:
```java
38
```java
Output:
```java
Temperature: 38 degrees
Level: Extreme heat
```java
38 >= 35 so "Extreme heat"
### Example 2: Comfortable Level
Input:
```java
18
```java
Output:
```java
Temperature: 18 degrees
Level: Comfortable
```java
15 <= 18 < 25 so "Comfortable"
### Example 3: Boundary Value (15)
Input:
```java
15
```java
Output:
```java
Temperature: 15 degrees
Level: Comfortable
```java
15 >= 15 so included in "Comfortable".
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
30
Expected Output:
Temperature: 30 °C Level: Hot
Normal case
Input:
8
Expected Output:
Temperature: 8 °C Level: Cold
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
