Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Finding the Largest Number Create a program that allows the user to enter sets o

ID: 3869566 • Letter: F

Question

Finding the Largest Number Create a program that allows the user to enter sets of integer values, in any order. Per set of data, the program is to output the largest number. Examples: a) Given the set of supplies values: (1,-3, 22,-30), the program should display 22, as the the largest value Given the set of supplied values: (52, 20, -9, 0, 7, 1500, 77, -15), the program should display 1500, as the largest value. Project Requirements: for a single execution of the program, the user man enter multiple sets of data, and for each set of data the program should find the largest number. Please do a program with "Visual logic program " (100%)

Explanation / Answer

Solution :-

The below given visual basic code simply implements a Form, where you can enter the number in an array. The numbers are shown in a list and you can get the highest number in the list by click the button DisplayMAX. Further you can clear the list and again input the new list of numbers and get the highest number again. B clicking the input values you can insert the numbers in the list. Clear button will clear the form and Exit button close the form.

The code is given below -

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Option Strict Off

Option Explicit On

  

Public Class Form1

Const intMAX_SUBSCRIPT As Integer = 10 'The max subscript

Dim intNumber(intMAX_SUBSCRIPT) As Integer 'An array to hold the numbers

Dim intHigh As Integer

Dim intCount As Integer                     'Loop Counter

Private Sub btnInputVal_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handles btnInputVal.Click

  

'Get the numbers and store them in an array.

For Me.intCount = 1 To intMAX_SUBSCRIPT

intNumber(intCount) = InputBox("Enter a number.")

  

Next

  

'Clear the list box of its current contents.

lstArrayValues.Items.Clear()

  

'Display the contents of the array in the listbox

lstArrayValues.Items.Add("Input Values")

For Me.intCount = 1 To intMAX_SUBSCRIPT

lstArrayValues.Items.Add(intNumber(intCount))

Next

End Sub

  

'Sub Routine for Higher Number

Private Sub HigherNum()

'Get the first element

intHigh = intNumber(0)

  

'Search for the Higest Value

For Me.intCount = 0 To (intNumber.Length - 1)

If intNumber(intCount) > intHigh Then

intHigh = intNumber(intCount)

End If

Next

  

lblHighest.Text = "The largest number is: " & intHigh.ToString()

  

End Sub

Private Sub btnDisplayMax_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) Handles btnDisplayMax.Click

'Call Higher Sub-Routine.

Call HigherNum()

End Sub

  

Private Sub btnExit_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handles btnExit.Click

'Close the form

Me.Close()

  

End Sub

  

Private Sub btnClear_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handles btnClear.Click

'Clear everything

lblHighest.Text = String.Empty

lstArrayValues.Items.Clear()

End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote