- Home
·
- Miscellaneous
·
- Calculate BMI (Body Mass Index), requires a simple input file created in notepad.
Calculate BMI (Body Mass Index), requires a simple input file created in notepad.
Calculate BMI (Body Mass Index), requires a simple input file created in notepad.
API Declarations
Dim weight(5) As Single
Dim Height1(5) As Single
Dim optweight(5) As String
Dim optweight2(3) As String
Dim counter As Integer
Dim bmi(5) As Single
Dim occurence(5) As Integer
Rate Calculate BMI (Body Mass Index), requires a simple input file created in notepad.
(1(1 Vote))
'
'
'exit the program
'
'
End
End Sub
Private Sub cmdstart_Click()
data_input Height1(), weight()
calculate_bmi weight(), bmi(), Height1()
calculate_weightbmi optweight2(), bmi(), optweight(), occurence()
display_results_bmi Height1(), weight(), bmi(), optweight2(), occurence()
End Sub
Private Sub data_input(ByRef Height1() As Single, weight() As Single)
Open "input2bmi.txt" For Input As #1
For counter = 1 To 5
Input #1, Height1(counter), weight(counter)
Next
Close #1
'
'
End Sub
Private Sub calculate_bmi(ByRef weight() As Single, bmi() As Single, Height1() As Single)
For counter = 1 To 5
bmi(counter) = weight(counter) / Height1(counter) ^ 2
Next
End Sub
Private Sub calculate_weightbmi(ByRef optweight2() As String, bmi() As Single, optweight() As String, occurence() As Integer)
'
Dim counternew As Integer
'
'
optweight2(1) = "underweight"
optweight2(2) = "ideal weight"
optweight2(3) = "overweight"
For counter = 1 To 5
Select Case bmi(counter)
Case Is < 18.5
optweight(counter) = "underweight"
Case Is >= 25
optweight(counter) = "overweight"
Case Is >= 18.5 < 25
optweight(counter) = "ideal weight"
End Select
Next
'
'calculate how many pupils scored in each band
'
For counternew = 1 To 3
For counter = 1 To 5
If optweight2(counternew) = optweight(counter) Then
occurence(counternew) = occurence(counternew) + 1
End If
Next
Next
'
End Sub
Private Sub display_results_bmi(ByRef Height1() As Single, weight() As Single, bmi() As Single, optweight2() As String, occurence() As Integer)
picout.Print "Height in meters"; Tab(30); "Weight in kilometers"; Tab(70); "BMI"
'
For counter = 1 To 5
picout.Print Height1(counter); Tab(30); weight(counter); Tab(70); FormatNumber(bmi(counter), 1)
Next
'
'display the club member weight analysis results
'
picdisplay.Print "category"; Tab(20); "number of members"; vbCrLf
'
'
For counter = 1 To 3
picdisplay.Print optweight2(counter); Tab(20); occurence(counter)
Next
'
End Sub
Calculate BMI (Body Mass Index), requires a simple input file created in notepad. Comments
No comments yet — be the first to post one!
Post a Comment