In: Computer Science
Guidelines
Look up one of the many sites describing the BMI, and read a bit about how it is used to indicate general health. Create a VB.Net program that, given a user’s height in inches and weight in pounds, will calculate and display his/her BMI. After calculating the user's BMI, indicate the user's health status.
BMI = (weight * 703) / (height * height)
Display the user’s Height Status:
BMI |
Health Status |
Below 18.5 |
Underweight |
18.5 -24.9 |
Normal |
25 - 29.9 |
Overweight |
30 & Above |
Obese |
Input: Height and Weight.
Output: BMI (to one decimal, like 27.7) and Weight Status (a string, like “Overweight”)
After the remarks at the top of your program, add “Option Explicit On” and “Option Strict On”. The former requires you to explicitly declare each variable used and the latter requires you to explicitly convert data from one type to another, rather than rely on VB.Net to implicitly convert data.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new Console Application in VB is created using Visual Studio 2017 with name "BMICalculator".This application contains a module with name "Module1.vb".
Module1.vb :
Option Explicit On
Option Strict On
Module Module1
'Main method
Sub Main()
'declaring variable to store height
Dim height As Double
'declaring variable to store weight
Dim weight As Double
'variable to store BMI
Dim BMI As Double
'variable to store health status
Dim healthStatus As String = ""
'asking user to enter height
Console.Write("Enter height in inches : ")
'reading height
height = Double.Parse(Console.ReadLine())
'asking user to enter weight
Console.Write("Enter weight in pounds : ")
'reading weight
weight = Double.Parse(Console.ReadLine())
'calculate BMI
BMI = (weight * 703) / (height * height)
'checking BMI for health status
If BMI < 18.5 Then
'if BMI is less than 18.5 then
healthStatus = "Underweight"
ElseIf BMI >= 18.5 And BMI < 24.9 Then
'if BMI is greater than or equal to 18.5 and less than 24.9
then
healthStatus = "Normal"
ElseIf BMI >= 25 And BMI < 29.9 Then
'if BMI is greater than or equal to 25 and less than 29.9
then
healthStatus = "Overweight"
ElseIf BMI >= 30 Then
'if BMI is greater than or equal to 30
healthStatus = "Obese"
End If
'display BMI
Console.WriteLine("BMI is " & BMI.ToString("0.0"))
'display health status
Console.WriteLine("Weight status : " & healthStatus)
'to hold the string
Console.ReadKey()
End Sub
End Module
======================================================
Output : Run application using F5 and will get the screen as shown below
Screen 1 :Module1.vb
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.