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

Hello, I am a BEGINNER using Microsoft Visual Studio. This problem comes from th

ID: 3802077 • Letter: H

Question

Hello, I am a BEGINNER using Microsoft Visual Studio. This problem comes from the "Microsoft Visual Basic 2015 RELOADED" book, chapter 9, page 499, exercise #25.

Here is the problem:

In this exercise, you code an application that displays the highest score earned on the midterm exam and the highest score earned on the final exam. Open the Highest Solution (Highest Solution.sln) file contained in the VbReloaded2015Chap09Highest Solution folder. Code the displayButton_Click procedure so that it displays (in the appropriate label controls) the highest score earned on the midterm exam and the highest score earned
on the final exam. Save the solution and then start and test the application. Close the solution. (2–4, 7, 11)

Here is the Highest Solution existing code and interface:

Also, the Options need to stay as is. Thank you for your help and work in this!

Main Form,vb x Main Form. vb [Design] Sa InitializeComponent Highest Project MainForm 1 Project name: Highest Project Displays the highest score earned on the midterm exam and the highest score Project purpose: earned on the final exam Created/revised by Kyour name> on 6 Option Explicit on Option Strict On 8 Option Infer Off 10 E Public Class MainForm 11 midterm scores are in the first column 12 final scores are in the second column 13 Private scores As Integer t 89, 98 178, 45), 167, 89 14 90 99 91 70 75 76 15 16 17 E Private sub exitButton Click (sender As object, e As EventArgs) Handles exitButton.click Me. Close 18 End Sub 19 20 End Class 21

Explanation / Answer

Lets see how we will solve this question: first you need to iterate over the 2D scores array. For this you need to know how many rows are there in this array. Here you can see it is 6 rows. But in case you dont want to count, there is a function GetLength( ) which will return the length a given dimesion in an array. In this example, there are 2 dimesions - 1st is no. of rows, and 2nd columns. To get the length of 1st dimension we use scores.GetLength(0), remember indexing always starts with 0. so 1st dimension is referred as 0. Now we already know 2 dimension is the columns which is 2.

So so access mid and final scores in the 4th set in scores, we use scores(3,0) and scores(3,1), where 3 is saying which row we want and 0 or 1 says which column. Again, indexing for rows / columns start from 0. So 3 means 4th row, 1 for column says 2nd column ! In general scores(i , j) means ith row and jth column in computer way of counting But i+1th row and j+1 column in our natural way of counting.

Now once we know how to access the elements in the 2D array, we are going to keep track of the current high scores for both mid and final. Each time we iterate over the scores array, we access the midscore, compare it with previous midhigh and if its more, save this number as the high and proceed further till end of list. Same happens with final high score as well. Finally we display the result in label/textbox by using syntax labelname.Text=midHigh or textboxname.Text=midhigh.

Since the question does not indicate the names of the controls where the result is to be displayed, it assumes lblmidhigh and lblfinalhigh as the name of the label controls on the form. Please replace it with proper names of the controls.

Hope that the answer and explaination helped. Please do rate the answer if it helped. Thank you very much.

Please use the following code in the displayButton_click procedure.

Dim i , len as Integer 'len stores the length of the 2D array scores i.e number of rows

Dim midHigh , finalHigh as Integer 'to store high maks in mid and final
'Initialize both the highs to 0
midHigh=0
finalHigh=0
  
len=scores.GetLength(0) 'use GetLength to get the length of 1st dimension
For i=0 To len-1
  
If(scores(i,0)>midHigh) then 'scores(i,0) refers to mid score in ith row
midHigh=scores(i,0)
End If
  
If(scores(i,1)>finalHigh) then 'scores(i,1) refers to final score in ith row
finalHigh=scores(i,1)
End If
  
Next i
  
lblMidHigh.Text=midHigh 'change lblMidHigh to correct label/textbox name
lblFinalHigh.Text=finalHigh 'change lblFinalHigh to correct label/textbox name
  

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