Question

In: Computer Science

Write a VB program to provide a health analysis. The higher the point total, the less...

Write a VB program to provide a health analysis. The higher the point total, the less healthy you are. Input will consist of the user's name, age group, smoker status, weight, sex, blood pressure, and cholesterol readings.

Risk Points are assigned as follows:

Age Group

18 or below0 points

19 - 301 point

31 - 602 points

over 604 points

Smoker?

Yes 5 points

No 0 points

Systolic Blood Pressure?

60 - 139 (Normal) 0 points

140 - 159 (Borderline) 2 points

over 159 (High) 4 points

Diastolic Blood Pressure?

40 - 89 (Normal) 0 points

90 - 94 (Borderline) 2 points

over 94 (High) 4 points

LDL (Bad) Cholesterol

< 110 0 points

110 and up 2 points

HDL (Good) Cholesterol

> 1/5 of Total Cholesterol 0 points

≤ 1/5 of Total Cholesterol 2 points

Weight

Female, over 200 lbs 3 points

Female, 150 - 200 lbs 2 points

Female, < 150 lbs 0 points

Male, over 260 lbs 3 points

Male, 200 - 260 lbs 2 points

Male, < 200 lbs 0 points

A sample user-interface design is attached for your use. Note that the user's name, and cholesterol readings are to be entered into textboxes. The sex and smoking status are entered via radio buttons. The weight and blood pressure (systolic and diastolic) are entered via Numeric UpDown controls. The age group is chosen from a combo box control.

The primary button on your form (Analyze Data) will contain all the code to solve this problem in its Click event procedure. You should also make this event procedure executable by simply pressing the ENTER key when the program runs.

Two other buttons...Quit (to pop up a "Farewell Greeting" message box to the user and stop program execution), and a Clear button (to reset all controls back to original values, and move the cursor back to the "Name" textbox), should also have their click event procedures coded.

Finally, a listbox should be included on your form to output the user's results as follows.

Note:

Total Cholesterol is LDL Cholesterol plus HDL Cholesterol.

Health Status is determined as follows:

Total Points Status

0 - 9Good

10 - 18Average

19 - 24Poor

Programming Notes

1. All code to solve this problem will be written in the "Analyze Data" Click event procedure. Therefore, all variables (meaningful, and properly data-typed) will be declared locally to this event procedure. No global (form-level) variables should be used.

2. The following variables and corresponding data types are suggested (You can add prefixes as needed).

Variable Data Type

namestring

weightinteger

HDLinteger

LDLinteger

TotalCholesterolinteger

SystolicBPinteger

DiastolicBPinteger

SmokePointsinteger

WtPointsinteger

AgePointsinteger

LDL Pointsinteger

HDL Pointsinteger

SystolicPointsinteger

DiastolicPointsinteger

TotalPointsinteger

HealthStatusstring

3. Code OPTION STRICT ON at class level to ensure all variables are properly declared in your program.

4. Use IF statements (single, dual, or multiple alternative, as needed) to determine points from Smoking, Systolic blood pressure, Diastolic blood pressure, HDL Cholesterol, LDL Cholesterol, and weight.

For example, suppose you want to assign points for user's smoking status. You would code the following:

Dim SmokePoints As Integer

If radSmokeYes.Checked = True Then

SmokePoints = 5

Else

SmokePoints = 0

End If

5. Use a Select/Case statement to determine points from the age group of the user.

6. Although you set the min/max for 40/300 for Systolic nud (in the Initial Properties Window), use data validation to ensure that user enters an integer between 60 and 200 inclusive into the Systolic Blood Pressure numeric updown control. If not, display an appropriate error message (via titled, descriptive message box), set insertion point back to Systolic Blood Pressure numeric updown control to allow the user to try again and Exit Sub to prevent further execution without having all the "input data.".

7. Do the same as in Step 6 above but set the min/max for 20/200 for Diastolic nud, for the Diastolic Blood Pressure reading, ensuring the user enters an integer between 40 and 120 inclusive.

I just need help with the coding of the project. Any help would be appreciated :)

Solutions

Expert Solution

hi,

Please find the output below:

when you click on CLear button

when you click on the Quit button

Belwo are the code

Public Class UserControl1
    Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles gpSex.Enter

    End Sub
''Button clear click
    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        txtnamestring.Text = ""
        txtHDLCholesterol.Text = ""
        txtLDLCholesteorol.Text = ""
        txtSystolicBloodPressure.Text = ""
        txtDiastolicBloodPressure.Text = ""
        txtWeight.ResetText()
        cmbAge.Text = ""
        rbtnFemale.Checked = False
        rbtnMale.Checked = False
        rbtnSmokeNo.Checked = False
        rbtnSmokerYes.Checked = False
        lstBox.Items.Clear()
    End Sub
''Button quit click
    Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click
        MessageBox.Show("Farewell Greeting")
        Application.Exit()
    End Sub
''Button Analyze data click
    Private Sub btnAnalyzeData_Click(sender As Object, e As EventArgs) Handles btnAnalyzeData.Click
        Dim namestring = txtnamestring.Text.Trim() ''get the name string

        Dim HDLChol = txtHDLCholesterol.Text.Trim() ''get the HDL cholestrol string
        Dim LDLChol = txtLDLCholesteorol.Text.Trim() ''get LDL the cholestrol string

        '' LDLPointsinteger HDLPointsinteger DiastolicPointsinteger TotalPointsinteger SystolicPointsinteger
        Dim SystolicBP = txtSystolicBloodPressure.Value()
        Dim DiastolicBP = txtDiastolicBloodPressure.Value()
        Dim SmokePointsinteger = rbtnSmokerYes.Checked
        Dim Weight = txtWeight.Value()
        Dim Age = cmbAge.SelectedItem()
 ''Check the Age range and add points in integer based on Age
        Dim AgePointsinteger As Integer
        Select Case Age
            Case "18 or below"
                AgePointsinteger = 0
            Case "19 - 30"
                AgePointsinteger = 1
            Case "31 - 60"
                AgePointsinteger = 2
            Case Else
                AgePointsinteger = 4
        End Select
''Check Smoke radio checked or not and accordigly add the points
        Dim SmokePointInteger As Integer
        If rbtnSmokerYes.Checked = True Then
            SmokePointInteger = 5
        Else
            SmokePointInteger = 0
        End If
''Check the BP Points Systolic range and add the points
        Dim SystolicBPPointsInteger As Integer
        If SystolicBP >= 60 AndAlso SystolicBP <= 139 Then
            SystolicBPPointsInteger = 0
        ElseIf SystolicBP >= 140 AndAlso SystolicBP <= 159 Then
            SystolicBPPointsInteger = 2
        ElseIf SystolicBP > 159 Then
            SystolicBPPointsInteger = 4
        End If
''Check the BP Points Diastolic range and add the points
        Dim DiastolicBPPointsInteger As Integer
        If DiastolicBP >= 40 AndAlso DiastolicBP <= 89 Then
            DiastolicBPPointsInteger = 0
        ElseIf DiastolicBP >= 90 AndAlso DiastolicBP <= 94 Then
            DiastolicBPPointsInteger = 2
        ElseIf DiastolicBP > 94 Then
            DiastolicBPPointsInteger = 4
        End If
''Check the LDL Pints based on LDL Chol range and assign value to LDLPintsinteger
        Dim LDLPointsinteger As Integer
        If LDLChol < 110 Then
            LDLPointsinteger = 0
        ElseIf LDLChol >= 110 Then
            LDLPointsinteger = 2
        End If
''Check total chlestroel and calculate the number
        Dim TotalCholesterolinteger As Integer = (LDLChol + HDLChol) / 5
        Dim HDLPointsinteger As Integer
        If TotalCholesterolinteger > HDLChol Then
            HDLPointsinteger = 0
        ElseIf TotalCholesterolinteger <= HDLChol Then
            HDLPointsinteger = 2
        End If
''Chck the sex of user and based on that finalize the range and output
        Dim sex As Integer
        If rbtnMale.Checked Then
            sex = 1
        Else
            sex = 2
        End If
''Check che weight based on range and do the calculations
        Dim WeightPointsinteger As Integer
        If sex = 1 Then
            If Weight > 200 Then
                WeightPointsinteger = 3
            ElseIf Weight >= 150 AndAlso Weight < 200 Then
                WeightPointsinteger = 2
            ElseIf Weight < 150 Then
                WeightPointsinteger = 1
            End If
        Else
            If Weight > 260 Then
                WeightPointsinteger = 3
            ElseIf Weight >= 200 AndAlso Weight < 260 Then
                WeightPointsinteger = 2
            ElseIf Weight < 200 Then
                WeightPointsinteger = 1
            End If
        End If
''get the status based on total calories
        Dim TotalPointsinteger = AgePointsinteger + SmokePointInteger + SystolicBPPointsInteger + DiastolicBPPointsInteger + LDLPointsinteger + HDLPointsinteger + WeightPointsinteger
        Dim sStatus As String
        If TotalPointsinteger >= 0 AndAlso TotalPointsinteger <= 9 Then
            sStatus = "Good"
        ElseIf TotalPointsinteger >= 10 AndAlso TotalPointsinteger <= 18 Then
            sStatus = "Average"
        Else
            sStatus = "Poor"
        End If

        lstBox.Items.Clear()

        lstBox.Items.Add(sStatus)
    End Sub

    Private Sub UserControl1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class

Thanks


Related Solutions

If the price is less than the average total cost but higher than the average variable...
If the price is less than the average total cost but higher than the average variable cost, then the firm is making a _________. a. loss and is making a negative contribution to fixed costs b. loss but will continue to produce in the short-run c. loss and will shut down in the short-run d. profit What two types of market scopes did Michael Porter use in developing his generic strategies model? Broad and narrow. Cost leadership and focus. Benefit...
The Medicare Program is a national health insurance program to provide health care for the aged...
The Medicare Program is a national health insurance program to provide health care for the aged and certain disabled persons, which of the following is INCORRECT? a. Part D-Medicare prescription drug coverage b. Part A-Nutrition Programs c.Part C-The Medicare Advantage Program d. Part B-Medical Insurance
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Provide an example of dissemination of evidence that influenced health policy. Provide a detailed analysis of...
Provide an example of dissemination of evidence that influenced health policy. Provide a detailed analysis of the evidence presented and the impact to our public health system.
Write a C++ program that will read in the number of nodes (less than 10) and...
Write a C++ program that will read in the number of nodes (less than 10) and a adjacency relation representing a graph. The program will create an adjacency matrix from the adjacency relation. The program will then print the following items: 1. Print the adjacency matrix 2. Determine if there are any isolated nodes and print them 3. Determine if an Euler path exists Sample run output Please input the number of nodes: 6 Please input the adjacency relation: {(1,2),(1,5),(2,1),(2,3),(3,2),(3,4),(4,3),(4,5),(5,1),(5,4)}...
Write a C++ program that will read in the number of nodes (less than 10) and...
Write a C++ program that will read in the number of nodes (less than 10) and a adjacency relation representing a graph. The program will create an adjacency matrix from the adjacency relation. The program will then print the following items: 1. Print the adjacency matrix 2. Determine if there are any isolated nodes and print them 3. Determine if an Euler path exists Sample run (to make program output more clear, I have put it in boldface): Please input...
​​​​​1) Write a program that defines a structure that represents a point. Your point structure should...
​​​​​1) Write a program that defines a structure that represents a point. Your point structure should contain members for the X and Y value. Write a function called distance that takes two points as parameters and returns the distance between them. Your program should define & print two points and display the distance between them. Copy your structure without formatting: Copy your distance function without formatting: 2) Write a C program that contains an array that contains the following value:...
response that correlates a country's financial health to its citizens' financial health. Provide an analysis of...
response that correlates a country's financial health to its citizens' financial health. Provide an analysis of data related to personal, corporate, or governmental decisions and the effects of these decisions on individual, family, or community spending. Provide at least two resources that support your analysis.
Program in Java code Write a program with total change amount in pennies as an integer...
Program in Java code Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. .Ex1: If the input is: 0 the output is:    No change            Ex2: If the input is:    45   the output is:   1 Quarter 2 Dimes
Write the c++ program of Secant Method and Fixed point Method in a one program using...
Write the c++ program of Secant Method and Fixed point Method in a one program using switch condition .Like : cout<<"1.Secant Method \n 2. Fixed point Method\n"<<endl; if press 1 then work Secant Method if press 2 then work Fixed point Method .so please writhe the code in c++ using switch case.and the equation given down consider the equation in the given.Note: Must showt the all the step of output all the iteration step shown in the program .in program...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT