Temperature Classification

Classify temperature as cold, moderate, or hot using conditions.

BeginnerTopic: Module 2: Conditional Programs
Back

Java Temperature Classification Program

This program helps you to learn the fundamental structure and syntax of Java programming.

Try This Code
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter temperature in Celsius: ");
        double temp = sc.nextDouble();

        if (temp < 10) {
            System.out.println("Cold");
        } else if (temp <= 30) {
            System.out.println("Moderate");
        } else {
            System.out.println("Hot");
        }

        sc.close();
    }
}
Output
Enter temperature in Celsius: 35
Hot

Understanding Temperature Classification

We define simple ranges: below 10 as cold, 10–30 as moderate, above 30 as hot.

Note: To write and run Java programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Java Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Java programs.

Table of Contents