Write a program to enter (15) numbers by using inputbox satement, then find (1):the average of positive numbers, (2):the summation of negative numbers, print the results in textboxes
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sumPositiveNumbers As Double = 0
Dim summationNegativeNumbers As Double = 0
Dim totalPositiveNumbers As Integer = 0
Dim number As Double = 0
For i As Integer = 0 To 14
number = Double.Parse(InputBox("Enter the number " + (i + 1).ToString() + ": "))
If number >= 0 Then
sumPositiveNumbers += number
totalPositiveNumbers += 1
Else
summationNegativeNumbers += number
End If
Next
Dim averagePositiveNumbers As Double = sumPositiveNumbers / totalPositiveNumbers
txtAveragePositiveNumbers.Text = averagePositiveNumbers.ToString()
txtSummationNegativeNumbers.Text = summationNegativeNumbers.ToString()
End Sub
End Class
Comments
Leave a comment