Write a C# Sharp program to read temperature in centigrade and display a suitable message according to temperature state below :
Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then Its Hot
Temp >=40 then Its Very Hot
Test Data :
42
Expected Output :
Its very hot.
using System;
using System.IO;
using System.Collections.Generic;
namespace App
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter temperature: ");
int Temp = int.Parse(Console.ReadLine());
//Temp < 0 then Freezing weather
if (Temp < 0) {
Console.WriteLine("Freezing");
}
//Temp 0-10 then Very Cold weather
if (Temp >= 0 && Temp < 10)
{
Console.WriteLine("Very Cold");
}
//Temp 10-20 then Cold weather
if (Temp >=10 && Temp < 20)
{
Console.WriteLine("Cold");
}
//Temp 20-30 then Normal in Temp
if (Temp >= 20 && Temp < 30)
{
Console.WriteLine("Normal");
}
//Temp 30-40 then Its Hot
if (Temp >= 30 && Temp < 40)
{
Console.WriteLine("Its Hot");
}
//Temp >=40 then Its Very Hot
if (Temp >= 40)
{
Console.WriteLine("Its Very Hot");
}
Console.ReadLine();
}
}
}
Comments