Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Visual Studio LINQ program

CSC139 Chapter 11 Lab Assignments

Objectives

In this lab assignment, students will learn:

- How to define LINQ statement

- How to use LINQ to query data from object array

Goals

In this lab assignment, students will demonstrate the abilities to:

- Define LINQ statement

- Use LINQ to query data from object array

Grading rubric 

  1. Create a console application “LINQGradeBook
  2. Add the following class definition:

Public Class GradeBook

    Private nameValue As String

    Private scoreValue As Integer

    Public Sub New(ByVal n As String, ByVal s As Integer)

        nameValue = n

        scoreValue = s

    End Sub

    Public Property Name() As String

        Get

            Return nameValue

        End Get

        Set(ByVal value As String)

            nameValue = value

        End Set

    End Property

    Public Property Score() As Integer

        Get

            Return scoreValue

        End Get

        Set(ByVal value As Integer)

            scoreValue = value

        End Set

    End Property

    Public Sub displayGradeBook()

        Console.WriteLine("Name: " & Name & vbTab & "Score: " & Score)

    End Sub

End Class

  1. Rename the file “Module1.vb” to “LINQGradeBookTester.vb
  2. Complete the missing code following the comments. You are required to create two LINQ statements which will select specific gradeBook object from a GradeBook objects array.

Option Strict On

Module LINQGradeBookTester

    Sub Main()

        Dim g1 As New GradeBook("AAA", 70)

        Dim g2 As New GradeBook("BBB", 50)

        Dim g3 As New GradeBook("CCC", 100)

        Dim g4 As New GradeBook("DDD", 80)

        'add g1, g2, g3 and g4 in a array and display all student scores

        Dim gradeBooks As GradeBook() = {g1, g2, g3, g4}

        display(gradeBooks, "Scores for all students: ")

'create a LINQ which get all scores in ascending order and display them.

        'create a LINQ which get all students who passed the exam

        'display number of passed students, their names and scores 

    End Sub

    'display gradeBook's information

    Private Sub display(ByVal gradeBooks As IEnumerable, ByVal header As String)

        Console.WriteLine(header)

        For Each g As GradeBook In gradeBooks

            g.displayGradeBook()

        Next

        Console.WriteLine()

    End Sub

End Module

Here is output: (See next page)

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question