Answer:
Step-by-step explanation:
Below is the code used to carry out this problem, i hope you try it out and apply it to other similar problems.
Code to Copy:
Public Class myFatCalculator
'calculating fat
Private Sub btnCalculateFat_Click(sender As Object, e As EventArgs) Handles btnCalculateFat.Click
Dim totCalories As Integer
Dim grams As Decimal
Dim fatCalories As Decimal
Dim fatPercentage As Decimal
Integer.TryParse(txtTotCalories.Text,totCalories)
Decimal.TryParse(txtGrams.Text, grams);
fatCalories=grams*9
fatPercentage=fatCalories/totCalories*100;
lblFatCalories.Text=fatCalories.ToString()
lblFatPercentage.Text=fatPercentage.ToString("N0")
End Sub
'Clear all text boxes & labels
Private Sub btnClearForm_Click(sender As Object, e As EventArgs)Handles btnClearFrom_Click
txtTotCalories.Clear()
txtTotCalories.Clear()
lblFatCalories.Clear()
lblFatPercentage.Clear() ‘clear labels
End Sub
'Exit from the Application
Private Sub btnExitApp_Click(sender As Object, e As EventArgs)Handles btnExitApp_Click
Application.Exit()
End Sub
'class ends
End Class
Coding:
Public Class myFatCalculator
'calculating fat
Private Sub btnCalculateFat_Click(sender As Object, e As EventArgs) Handles btnCalculateFat.Click
Dim totCalories As Integer
Dim grams As Decimal
Dim fatCalories As Decimal
Dim fatPercentage As Decimal
Integer.TryParse(txtTotCalories.Text,totCalories)
Decimal.TryParse(txtGrams.Text, grams);
fatCalories=grams*9
fatPercentage=fatCalories/totCalories*100;
lblFatCalories.Text=fatCalories.ToString()
lblFatPercentage.Text=fatPercentage.ToString("N0")
End Sub
'Clear all text boxes & labels
Private Sub btnClearForm_Click(sender As Object, e As EventArgs)Handles btnClearFrom_Click
txtTotCalories.Clear()
txtTotCalories.Clear()
lblFatCalories.Clear()
lblFatPercentage.Clear() ‘clear labels
End Sub
'Exit from the Application
Private Sub btnExitApp_Click(sender As Object, e As EventArgs)Handles btnExitApp_Click
Application.Exit()
End Sub
'class ends
End Class
cheers i hope this helped !!!!