michael040990
03-06-2010, 04:32 PM
hello this is my first post i'm having trouble making a program that determines the Body Mass Index of a person and also display if they are over weight or under weight i have my source written up and part of it just isn't working i am wondering if someone can help me fix it or at least help me find the problem thank you. don't be to critical i'm new to programming here's the source.
Module Module1
'Program: bmi
'Programmer: Michael Burns
'Date: 3/6/1020
'Description: calculates the bmi of a person and determines if it is normal, under, or over weight..
Dim decWeight As Decimal = 0
Dim decHight As Decimal = 0
Dim decBmi As Decimal = 0
Dim decBmi2 As Decimal = 0
Sub Main()
'Declaration
'Input
getInput(decWeight, decHight)
'Process
calculate()
'Output
display()
terminateProgram()
End Sub
Private Sub getInput(ByRef decWeight As Decimal, ByRef decHight As Decimal)
Console.Write("Enter your Weight in Pounds: ")
decWeight = CDec(Console.ReadLine())
Console.Write("Enter your Height in inches: ")
decHight = CDec(Console.ReadLine())
End Sub
Private Sub calculate()
'Declaration
Dim decBmi = decWeight * 703 / decHight ^ 2
'Determine
If decBmi >= 18.5 And decBmi <= 25 Then
decBmi2 = 1
Else
If decBmi < 18.5 Then
decBmi2 = 2
End If
End If
End Sub
Private Sub display()
Console.WriteLine()
Console.WriteLine("Your BMI is: " & decBmi)
If decBmi2 = 1 Then
Console.WriteLine()
Console.WriteLine("Your BMI is Optimal. ")
Else
If decBmi2 = 2 Then
Console.WriteLine()
Console.WriteLine("Your BMI is Under Weight. ")
Else
Console.WriteLine()
Console.WriteLine(" Your BMI is Over Weight.")
End If
End If
End Sub
Private Sub terminateProgram()
Console.WriteLine()
Console.Write("Press the enter key to end the program.")
Console.Read()
End Sub
End Module
Module Module1
'Program: bmi
'Programmer: Michael Burns
'Date: 3/6/1020
'Description: calculates the bmi of a person and determines if it is normal, under, or over weight..
Dim decWeight As Decimal = 0
Dim decHight As Decimal = 0
Dim decBmi As Decimal = 0
Dim decBmi2 As Decimal = 0
Sub Main()
'Declaration
'Input
getInput(decWeight, decHight)
'Process
calculate()
'Output
display()
terminateProgram()
End Sub
Private Sub getInput(ByRef decWeight As Decimal, ByRef decHight As Decimal)
Console.Write("Enter your Weight in Pounds: ")
decWeight = CDec(Console.ReadLine())
Console.Write("Enter your Height in inches: ")
decHight = CDec(Console.ReadLine())
End Sub
Private Sub calculate()
'Declaration
Dim decBmi = decWeight * 703 / decHight ^ 2
'Determine
If decBmi >= 18.5 And decBmi <= 25 Then
decBmi2 = 1
Else
If decBmi < 18.5 Then
decBmi2 = 2
End If
End If
End Sub
Private Sub display()
Console.WriteLine()
Console.WriteLine("Your BMI is: " & decBmi)
If decBmi2 = 1 Then
Console.WriteLine()
Console.WriteLine("Your BMI is Optimal. ")
Else
If decBmi2 = 2 Then
Console.WriteLine()
Console.WriteLine("Your BMI is Under Weight. ")
Else
Console.WriteLine()
Console.WriteLine(" Your BMI is Over Weight.")
End If
End If
End Sub
Private Sub terminateProgram()
Console.WriteLine()
Console.Write("Press the enter key to end the program.")
Console.Read()
End Sub
End Module