Question

I need help regarding my Visual Basic code

ISC/ITE 285 Homework Due: Monday, January 28 by 11:55 pm Create a text file named Grades.txt which will contain a list of numeric grades. Save the file in the projects Bin/Debug folder. A sample of the file contents is shown below: 80 96 95 86 54 97 Create a string array that will be populated from the file Grades.txt when the array is created (Class-level array). Also create a numeric array that will hold the same values as the string array but as data type of Double. At load time, use the ReDim statement to size the numeric array and a For loop to give it values (using the information that was loaded into the string array) Note: Using the step above, once the form becomes available, both arrays will have been created and populated Code the three button click events shown on the form below: Text Files List All Grades Traverse (read through) the numeric array and list all values in the listbox Display Statistics Display the highest grade, lowest grade, and average of all grades in the listbox List All with Given Grade - Ask the user to enter a letter grade (A, B, C D, or F). Traverse the numeric array and list all numeric values that would receive the given grade. At the end of the list, give a total count of the number of students who would receive the given grade List All Grades Display Statistics List All with Given Grade Notes: With this lab, you may use functions and subprocedures as you see fit. No data validation is required.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the solution:

Imports System.IO

Public Class frmMain
    Dim strFileLine As String
    Dim arrLines As New ArrayList() 'array list to store value
    Dim objReader As System.IO.StreamReader
    Dim iRowCount As Integer = 0 ' Variable to hold the total

    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub

    Private Sub btnListAllGrades_Click(sender As Object, e As EventArgs) Handles btnListAllGrades.Click
        lstOutput.Items.Clear() 'clear list items
        'check the file on button click load if exist
        'give the proper path of the file
        Dim fileReader As String = "MacHomeDocumentsVisual Studio 2017VBStudentGradeFileStudentGradeFileinDebugGrades.txt" 'For checking the file exist or not
        MessageBox.Show(If(File.Exists(fileReader), "File exists.", "File does not exist.")) 'Message give you file exist

        If System.IO.File.Exists(fileReader) = True Then
            ' read the file's lines into an ArrayList
            objReader = New System.IO.StreamReader(fileReader)
            Do While objReader.Peek() <> -1
                'add the file item to arraylist and listbox
                strFileLine = objReader.ReadLine()
                arrLines.Add(strFileLine)
                lstOutput.Items.Add(strFileLine)
            Loop
            objReader.Close() 'close reader
        Else
            MessageBox.Show(fileReader & " File does not exist") 'message file doesnot exist
        End If
    End Sub

    Private Sub btnDisplayStatistics_Click(sender As Object, e As EventArgs) Handles btnDisplayStatistics.Click
        lstOutput.Items.Clear() 'clear list items
        'check the file on button click load if exist
        Dim fileReader As String = "MacHomeDocumentsVisual Studio 2017VBStudentGradeFileStudentGradeFileinDebugGrades.txt" 'For checking the file exist or not
        MessageBox.Show(If(File.Exists(fileReader), "File exists.", "File does not exist.")) 'Message give you file exist

        If System.IO.File.Exists(fileReader) = True Then
            ' read the file's lines into an ArrayList
            objReader = New System.IO.StreamReader(fileReader)
            Do While objReader.Peek() <> -1
                'add the file item to arraylist and listbox
                strFileLine = objReader.ReadLine()
                arrLines.Add(strFileLine)

            Loop
            Dim sum As Integer = 0
            Dim min As Integer = Integer.MaxValue, max As Integer = Integer.MinValue, Value As Integer = 0
            sum = arrLines(0)
            For i As Integer = 1 To arrLines.Count - 1
                Value = arrLines(i)

                If Value < min Then
                    min = Value
                End If

                If Value > max Then
                    max = Value
                End If
                sum = sum + arrLines(i)

            Next
            objReader.Close() 'close reader
            lstOutput.Items.Add("Maximum is: " & max)
            lstOutput.Items.Add("Minimum is: " & min)
            lstOutput.Items.Add("Average is: " & sum / arrLines.Count)
        Else
            MessageBox.Show(fileReader & " File does not exist") 'message file doesnot exist
        End If
    End Sub

    Private Sub btnListAllwithGivenGrades_Click(sender As Object, e As EventArgs) Handles btnListAllwithGivenGrades.Click

    End Sub
End Class

output:

Text Files List Al Grades 80 78 96 95 86 54 97 Display Statistics List All with Given Grades

Text Files Maximum is: 99 Minimum is: 54 Average is: 85.625 List All Grades Display Statistics List All with Given Grades

Add a comment
Know the answer?
Add Answer to:
I need help regarding my Visual Basic code ISC/ITE 285 Homework Due: Monday, January 28 by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming Language Edit and modify from the given code Perform the exact same logic, except...

    Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....

  • I need help with my C coding homework. If possible can you please comment to help...

    I need help with my C coding homework. If possible can you please comment to help me understand whats going on in the code. Thanks in advance. Create a C program (3 points): o At the top of the file include the following comments: Your name The purpose (core concept found below) of the program The date created o Create two int variables: Initialize each to different values. o Create three pointers: Point the first two pointers to the first...

  • Hi, I need help with my comp sci assignment. The parameters are listed below, but I...

    Hi, I need help with my comp sci assignment. The parameters are listed below, but I am having trouble generating the number of occurrences of each word. Please use a standard library. Read in the clean text you generated in part 2 (start a new cpp file). Create a list of all the unique words found in the entire text file (use cleanedTextTest.txt for testing). Your list should be in the form of an array of structs, where each struct...

  • Hi I was hoping to get some help with my code for this problem. I don't...

    Hi I was hoping to get some help with my code for this problem. I don't know how to correctly read a txt file and the difference between using string and cstring. My code is at the bottom please help thanks. 1. Create the following “data.txt” file. Each record consists of customer's name and their balance: Maria Brown 2100.90 Jeffrey Jackson 200.20 Bernard Smith 223.10 Matthew Davenport 1630.20 Kimberly Macias 19100.90 Amber Daniels 2400.40 The records in the file will...

  • I NEED HELP with this. please create a UML diagram. I need a simple code to...

    I NEED HELP with this. please create a UML diagram. I need a simple code to solve the problem.   The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should...

  • I've done all questions except question 6. how do I do this? please help. code needs...

    I've done all questions except question 6. how do I do this? please help. code needs to be java 1. You need to be able to open and read the text files that have been provided for the project. Write a Java program that reads the driver.txt file and displays each data value for each line from the file to the screen in the following format: Licence Number: Licence Class: First Name: Last Name: Address: Suburb: Postcode: Demerit Points: Licence...

  • I need help figuring out how to code this in C++ in Visual Studio. Problem Statement:...

    I need help figuring out how to code this in C++ in Visual Studio. Problem Statement: Open the rule document for the game LCR Rules Dice Game. Develop the code, use commenting to describe your code and practice debugging if you run into errors. Submit source code. Use the document to write rules for the user on how to play the game in a text file. Then, using the information from the resource articles, create a program that will read...

  • Please help. I need a very simple code. For a CS 1 class. Write a program...

    Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...

  • pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the...

    pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the last assignment by providing the following additional features: (The additional features are listed in bold below) Class Statistics In the class Statistics, create the following static methods (in addition to the instance methods already provided). • A public static method for computing sorted data. • A public static method for computing min value. • A public static method for computing max value. • A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT