Temperature Scale Program in C#(Sharp)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TemperatureScale { class Program { static void Main(string[] args) { /* Temperature Scale Program * we are using the Replace() for the Removing the C from the use input. * we are checking the result value it is numeric or not. * we are using if statement. if isNum is true then execute the if blcok */ string result = args[0]; result = result.Replace("C",""); double Num; bool isNum1 = double.TryParse(result, out Num); if (isNum1) { double celsius = Convert.ToDouble(result); double kelvin = celsius + 273; double Fahrenheit = celsius * 18 / 10 + 32; Console.WriteLine("{0}K,{1}F", kelvin, Fahrenheit); } else { Console.WriteLine("Please input the write Temperature"); } } } }
No comments:
Post a Comment