Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Visual Basic- The file Scores.txt contains scores between 1 and 49. Write a program that uses these scores to create an array of frequencies as

Visual Basic-

The file Scores.txt contains scores between 1 and 49. Write a program that uses these scores to create an array of frequencies as follows:

frequencies(0) = # of scores 0 -9 frequencies(1) = # of scores with 10 frequencies(2) = # of scores with 20 frequencies(3) = # of scores with 30 frequencies(4) = # of scores with 40

The program should then display the results in tabular form, as shown below.

Guidelines: Must use a Split Array. Do NOT use numeric literal for index. Create constants to represent the index. Use a counter. Text text is read in using 'IO.File.ReadAllLines". Please make the coding as simple as possible while following the above guidelines.

.image text in transcribed

PLEASE DO NOT USE THIS CODING. IT DOES NOT WORK WITH MY PROGRAM.---

Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click 'Array to store the results Dim frequency(4) As Integer Dim fmtStr As String = "{0,-12} {1,-9:N0}" 'Open the data file for input Dim strDigits() As String = IO.File.ReadAllLines("Scores.txt") For i As Integer = 1 To strDigits.Count - 1 frequency(CInt(Int(strDigits(i) / 10))) += 1 Next 'Display the results. lstOutput.Items.Add(String.Format(fmtStr, "Interval", "Frequency")) For i As Integer = 0 To 4 lstOutput.Items.Add(String.Format(fmtStr, CStr(i * 10) & " to " & CStr((i + 1) * 10 - 1), frequency(i))) Next End Sub End Class

a a Frequencies Display Frequencies Interval Frequency 0 to 9 10 to 19 20 to 29 30 to 39 40 to 49 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions