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