Answer to Question #243455 in C# for Gayatri

Question #243455

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.


1
Expert's answer
2021-09-30T04:45:56-0400
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();
        }






    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS