Conversion of Temperatures is not executing perfectly

Feb 15 2012 5:22 AM
Here is the following code & getting an error in it can u please solve it




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Employee
{
   public static class TempConverter
    {
       public static double CelsiusToFahrenheit(string TempCelsius)
       {
           double Celsius = double.Parse(TempCelsius);
           double Fahren=(Celsius*9/5)+32;
           return Fahren;
       }

       public static double FahrenheitToCelsius(string TempFahren)
       {
           double Fahren = double.Parse(TempFahren);
           double Celsius = (Fahren - 32) * 5 / 9;
           return Celsius;
       }
    }

   class TemperatureStatic
   {
       static void Main(string[] args)
       {
           Console.WriteLine("Select the Conversion Direction");
           Console.WriteLine("1.Celsius to FahrenHeit");
           Console.WriteLine("2.FahrenHeit to Celsius");
           Console.Write("You selected :");

           double F, C = 0;
           string selection = Console.ReadLine();

           switch (selection)
           {
               case "1":
                   Console.WriteLine("PLease Enter Celsius Temperature");
                   F = TempConverter.CelsiusToFahrenheit(Console.ReadLine());
                   Console.WriteLine("Temperature in FahrenHeit is {O:F2}",F); break;

               case "2":
                   Console.WriteLine("PLease Enter FahrenHiet Temperature");
                   C = TempConverter.FahrenheitToCelsius(Console.ReadLine());
                   Console.WriteLine("Temperature in Celsius is {O:F2}",C); break;
               default:
                   Console.WriteLine("Please Select the Convertor");break;
           }
       }
   }
}


Answers (1)