Esempio n. 1
0
        public static void Main()
        {
            string input  = Console.ReadLine();
            string output = String.Empty;

            while (input != "End")
            {
                string[] splittedInput = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                int    degrees = int.Parse(splittedInput[0]);
                string system  = splittedInput[1];

                if (system == "Celsius")
                {
                    output = TemperatureConverter.CelsiusToFahrenheit(degrees);
                }
                else
                {
                    output = TemperatureConverter.FahrenheitToCelsius(degrees);
                }

                Console.WriteLine(output);

                input = Console.ReadLine();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            while (input != "End")
            {
                string[] tempereturArgs = input.Split();
                int      tempereture    = int.Parse(tempereturArgs[0]);
                switch (tempereturArgs[1])
                {
                case "Celsius":
                    Console.WriteLine(TemperatureConverter.ConvertToF(tempereture) + " Fahrenheit");
                    break;

                case "Fahrenheit":
                    Console.WriteLine(TemperatureConverter.ConvertToC(tempereture) + " Celsius");
                    break;
                }
                input = Console.ReadLine();
            }
        }
        public static void Main()
        {
            var inputLine = Console.ReadLine();

            while (!inputLine.Equals("End"))
            {
                var tokens = inputLine.Split();
                var value  = double.Parse(tokens[0]);
                var type   = tokens[1];

                if (type.Equals("Celsius"))
                {
                    Console.WriteLine($"{TemperatureConverter.FromCelsiusToFahrenheit(value):f2} Fahrenheit");
                }
                else
                {
                    Console.WriteLine($"{TemperatureConverter.FromFahrenheitToCelsius(value):f2} Celsius");
                }

                inputLine = Console.ReadLine();
            }
        }