K – Is it hot or cold

Chef considers the climate HOT if the temperature is above 2020, otherwise he considers it COLD. You are given the temperature 𝐶C, find whether the climate is HOT or COLD.

Input Format

  • The first line of input will contain a single integer 𝑇T, denoting the number of test cases.
  • The first and only line of each test case contains a single integer, the temperature 𝐶C.

Output Format

For each test case, print on a new line whether the climate is HOT or COLD.

You may print each character of the string in either uppercase or lowercase (for example, the strings hOthotHot, and HOT will all be treated as identical).

Constraints

  • 1≤𝑇≤501≤T≤50
  • 0≤𝐶≤400≤C≤40

Sample 1

InputcopyOutputcopy
2 21 16HOT COLD

Test case 11: The temperature is 2121, which is more than 2020. So, Chef considers the climate HOT.

Test case 22: The temperature is 1616, which is not more than 2020. So, Chef considers the climate COLD.

Solutions:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt(); 
        
        for (int i = 0; i < T; i++) {
            int C = scanner.nextInt(); 
            if (C > 20) {
                System.out.println("HOT");
            } else {
                System.out.println("COLD");
            }
        }
        scanner.close();
    }
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top