Question
Build an application in visual basic based upon the Temperature Converter application code listed below Include the following additions to the Conversion Selection group: Celsius
Build an application in visual basic based upon the Temperature Converter application code listed below
Include the following additions to the Conversion Selection group:
Celsius to Kelvins
Kelvins to Celsius
Fahrenheit to Kelvins
Kelvins to Fahrenheit
Code Listing:
Public Class frmTemperatureConverter
Private Sub frmTemperatureConverter_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
lblConversionInstruction.Text = " "
lblTempOutput.Text = " "
lblInputTempText.Text = " "
lblOutputTempText.Text = " "
txtTempInput.Clear()
radFahrenheitToCelsius.Checked = True
radCelsiusToFahrenheit.Checked = False
End Sub
Private Sub btnConvert_Click(sender As System.Object, e As System.EventArgs) Handles btnConvert.Click
Dim decInputTemp As Decimal
Dim decOutputTemp As Decimal
decInputTemp = Convert.ToDecimal(txtTempInput.Text)
If radCelsiusToFahrenheit.Checked = True Then
decOutputTemp = CelsiusToFahrenheit(decInputTemp)
lblTempOutput.Text = Convert.ToString(decOutputTemp)
lblInputTempText.Text = "Degrees Celsius"
lblOutputTempText.Text = "Degrees Fahrenheit"
ElseIf radFahrenheitToCelsius.Checked = True Then
decOutputTemp = FahrenheitToCelsius(decInputTemp)
lblTempOutput.Text = Convert.ToString(decOutputTemp)
lblInputTempText.Text = "Degrees Fahrenheit"
lblOutputTempText.Text = "Degrees Celsius"
End If
End Sub
Private Function CelsiusToFahrenheit(ByVal decInputTemp As Decimal)
Dim decCelsiusTemp As Decimal
decCelsiusTemp = (decInputTemp * 9 / 5) + 32.0
Return decCelsiusTemp
End Function
Private Function FahrenheitToCelsius(ByVal decInputTemp As Decimal)
Dim decFahrenheitTemp As Decimal
decFahrenheitTemp = (decInputTemp - 32.0) * (5 / 9)
Return decFahrenheitTemp
End Function
End Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started