/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 208 - Problem 5: Temperature Convertor (b) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static void Main(string[] args) { float temp; int userMenu; //display the unit menu Console.WriteLine("Please select the unit to start with: "); Console.WriteLine("\t\tPress (1) for C\n\t\tPress (2) for F\n\t\tPress (3) for K"); Console.Write("Your selection: "); userMenu = int.Parse(Console.ReadLine()); //read the temperature Console.Write("\nPlease enter the temperature: "); temp = float.Parse(Console.ReadLine()); //Display the results if(userMenu == 1) Console.WriteLine("\n\n{0} C ---> {1:0.0000} F\n{2} C ---> {3:0.0000} K", temp, (temp * 9f / 5) + 32, temp, temp + 273.15); else if (userMenu == 2) Console.WriteLine("\n\n{0} F ---> {1:0.0000} C\n{2} F ---> {3:0.0000} K", temp, (temp - 32) * 5 / 9, temp, ((temp - 32) * 5 / 9) + 273.15); else Console.WriteLine("\n\n{0} K ---> {1:0.0000} C\n{2} K ---> {3:0.0000} F", temp, temp - 273.15, temp, ((temp - 273.15) * 9f / 5) + 32); if (userMenu == 2) temp = (temp - 32) * 5 / 9; else if (userMenu == 3) temp = temp - 273.15f; //check the cold level if (temp <= 0) Console.WriteLine("\nVery Cold"); else if (temp <= 10) Console.WriteLine("\nCold"); else if (temp <= 20) Console.WriteLine("\nWarm"); else if (temp <= 30) Console.WriteLine("\nHot"); else Console.WriteLine("\nVery Hot"); Console.ReadKey(); } } }