Answer to Question #279996 in Visual Basic for Malik8886

Question #279996

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

1
Expert's answer
2021-12-15T16:23:28-0500
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






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS