Problem

Write a program to ask the user to give temperature in Fahrenheit and then the program will convert the given temperature into Celsius equivalent. 

Formula to convert Fahrenheit to Celsius below

 °C = (°F  –  32)  x  5/9

Example 

50°F = 10°C ( (50°F – 32) multiplied by 5/9 = 10°C )

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.

Program Listing

' Fahrenheit To Celsius in VB.NET
' Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
' www.jakerpomperada.com  and www.jakerpomperada.blogspot.com
' jakerpomperada@gmail.com
' Bacolod City, Negros Occidental Philippines
' May 17, 2021   Monday  3:56 PM

Public Class Form1

    Shared Function ConvertF2C(f As Double) As Double
        Return (f - 32) * 5 / 9
    End Function

    Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click

        Dim temperature As Double
        Dim result As Double

        temperature = Val(txtFahrenheit.Text)
        If txtFahrenheit.Text = "" Or IsNumeric(txtFahrenheit.Text) = False Then
            MessageBox.Show("Please enter temperature in Fahrenheit.", "Reminder", MessageBoxButtons.OK, MessageBoxIcon.Question)
            txtFahrenheit.Text = ""
            txtFahrenheit.Focus()
        Else
            result = ConvertF2C(temperature)
            txtCelsius.Text = result.ToString("#####.##") & "°C"
            txtCelsius.ReadOnly = True
        End If
    End Sub

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        txtFahrenheit.Text = ""
        txtCelsius.Text = ""
        txtFahrenheit.Focus()
    End Sub

    Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click
        Dim result = MessageBox.Show(" Are you sure you want to quit the program?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = DialogResult.Yes Then
            Me.Close()
        Else
            Me.Show()
            txtFahrenheit.Text = ""
            txtCelsius.Text = ""
            txtFahrenheit.Focus()
        End If
    End Sub
End Class

Leave a Reply

Your email address will not be published.