Write a program that calculates average daily temperatures and summary statistics. The user will be prompted to enter a Fahrenheit temperature as a value with one decimal place and to select the name of the technician entering the temperature. The user will have the option to see the Celsius equivalent of the entered Fahrenheit temperature. The program will display the average temperature of all entered temperatures. The results are displayed when the user hits ENTER, uses the access key or clicks the Calculate button. The user will be given the opportunity to enter another temperature when the user hits ESC, uses the access key or clicks the Clear button. The user will exit the program by clicking the Exit button or using its access key. The Exit button will also display the summary statistics: 1) the number of temperatures entered by each technician and 2) the average temperature of all entered temperatures. Calculations should only be done if a numeric value between 32.0 and 80.0 (inclusive) degrees for temperature is entered and a technician has been selected.
Below is what I have so far. I still need to format it so it is organized better. It does what I want it to do but not exactly. I keep getting an error when I hit the clear button as well. Can anyone help me fix the error and help me with the end stastistics so it actually displays the numbers instead of just the property name?
And also it is not doing what I would like it to do as far as storing each number that I enter to determine the average. Can anyone help?
Option Strict On
Imports System.Convert
Imports Microsoft.VisualBasic.ControlChars
Public Class Form1
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim intEntriesJen As Integer = 0
Dim intEntriesCliff As Integer = 0
If radJen.Checked = True Then
intEntriesJen += 1
End If
If radCliff.Checked = True Then
intEntriesCliff += 1
End If
Dim dblAvg As Double
dblAvg = CDbl(txtTemp.Text) / intEntriesJen + intEntriesCliff
lblAverage.Text = CStr(dblAvg)
End Sub
Private Sub chkCelsius_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCelsius.CheckedChanged
Dim dblCelsius As Double
dblCelsius = (CDbl(txtTemp.Text) - 32) * 5 / 9
lblCelsius.Text = CStr(dblCelsius)
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
' Clear the numbers
txtTemp.Clear()
lblAverage.Text = String.Empty
lblCelsius.Text = String.Empty
radCliff.Checked = False
radJen.Checked = False
chkCelsius.Checked = False
' Reset the focus
txtTemp.Focus()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
'Ends Application and shows summary statistics
MessageBox.Show("Jen entered intEntriesJen entries." & ControlChars.CrLf & "Cliff entered intEntriesCliff entries." & _
ControlChars.CrLf & "The average temperature is _.", "Status")
Me.Close()
End Sub
End Class

Add Reply




MultiQuote

| 


