Implement Temperature Comparison Utility

Beginner

Introduction

In this challenge, you will develop a C++ program that classifies temperature readings into three categories: Cold, Mild, and Hot. The program will use relational and logical operators to determine the temperature ranges and print the corresponding category to the console. This tool will help meteorological scientists quickly categorize temperature data for their research.


Skills Graph

Implement Temperature Comparison Utility

As a junior meteorological assistant, you'll develop a tool to help scientists quickly categorize temperature readings based on predefined conditions.

Tasks

  • Create a C++ program that classifies temperatures into categories
  • Use relational and logical operators to determine temperature ranges
  • Implement temperature classification with predefined ranges

Requirements

  • Create a file named temperature_classifier.cpp in the ~/project directory
  • Use C++ relational operators (<, >, ==) for comparison
  • Define three temperature categories:
    • Cold: Temperature < 10 degrees
    • Mild: Temperature between 10 and 25 degrees (inclusive)
    • Hot: Temperature > 25 degrees
  • Print the category to the console

Examples

Compile and run the program to test different temperature readings and verify the classification results.

## Compile the program
g++ -o temperature_classifier temperature_classifier.cpp

## Run the program
./temperature_classifier
Enter temperature: 5
Cold
Enter temperature: 20
Mild
Enter temperature: 30
Hot

Hints

  • Use ternary operator (?:) for concise classification
  • Remember to include <iostream> for I/O operations
  • Consider using string variable to store category

Summary

This challenge requires implementing a temperature classification program that categorizes readings into Cold, Mild, and Hot based on specified ranges. The program should demonstrate proper use of conditional logic and provide clear console output.