static void Main(string[] args) { Console.WriteLine("Please Select the converter"); Console.WriteLine("1.Celcius To Faherenheit"); Console.WriteLine("2.Faherenheit To Celcius"); Console.WriteLine(":"); string selection = Console.ReadLine(); double F, C = 0; switch (selection) { case "1": Console.WriteLine("Please enter the celcius temperature"); F = TemperatureConverter.CelciusToFahrenheit(Console.ReadLine()); Console.WriteLine("Temperature in Fahrenheit:" + F); break; case "2": Console.WriteLine("Please enter the faherenheit temperature"); C = TemperatureConverter.FahrenheitToCelcius(Console.ReadLine()); Console.WriteLine("Temperature in Celcius:" + C); break; default: Console.WriteLine("Please select"); break; } }
public void TestFahrenheitToCelcius() { var temperatureConverter = new TemperatureConverter(); temperatureConverter.SetTemperature(41.0); Assert.AreEqual(5.0, temperatureConverter.FahrenheitToCelcius()); }
public void TempConv_Test() { //TRUE Assert.Equal(32, TemperatureConverter.CelciusToFahrenheit(0)); Assert.Equal(10, TemperatureConverter.FahrenheitToCelcius(50)); Assert.Equal(373.15, TemperatureConverter.CelciusToKelvin(100)); // //FALSE // Assert.Equal(101.85,TemperatureConverter.KelvinToCelcius(375)); // Assert.Equal(215.33,TemperatureConverter.KelvinToFahrenheit(375)); // Assert.Equal(262.039,TemperatureConverter.FahrenheitToKelvin(12)); }
protected void SubmitButton_Click(object sender, EventArgs e) { if (Page.IsValid) { int start = int.Parse(TextBoxStart.Text); int end = int.Parse(TextBoxEnd.Text); int steps = int.Parse(TextBoxStep.Text); int difference = 0; TableHeaderRow headRow = new TableHeaderRow(); TempTable.Rows.Add(headRow); TableHeaderCell cCell = new TableHeaderCell { Text = "°C" }; TableHeaderCell fCell = new TableHeaderCell { Text = "°F" }; if (RadioButtonList.SelectedValue == "C") { headRow.Cells.Add(cCell); headRow.Cells.Add(fCell); } else { headRow.Cells.Add(fCell); headRow.Cells.Add(cCell); } while (end >= start) { if (RadioButtonList.SelectedValue == "C") { difference = TemperatureConverter.CelciusToFahrenheit(start); } else { difference = TemperatureConverter.FahrenheitToCelcius(start); } TableRow tRow = new TableRow(); TempTable.Rows.Add(tRow); TableCell Cell = new TableCell(); Cell.Text = Convert.ToString(start); tRow.Cells.Add(Cell); TableCell Cell2 = new TableCell(); Cell2.Text = Convert.ToString(difference); tRow.Cells.Add(Cell2); start += steps; } TempTable.Visible = true; } }