Answer to Question #179801 in Visual Basic for Anna

Question #179801

A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores. Write a program, Pseudo code and draw a TOE chart and -Flowchart that uses an array of string objects to hold the five student names, an array of one character to hold the five students’ letter grades, and five arrays of doubles to hold each student’s set of test scores and average score. The program should allow the user to enter each student’s name and his or her four test scores. The program should store each student’s information in the arrays [20 points]. It should then calculate and display each student’s average test score [20 points] and a letter grade based on the average [20 points]. Input Validation: Do not accept test scores less than 0 or greater than


1
Expert's answer
2021-04-11T22:41:16-0400
Pseudo code

 
Start
       Read the five student names from the user.
       Read the student four test scores. 
       Add student’s information to the arrays 
       Calculate each student’s average test score
       Calculate each student’s letter grade based on the average
       Display each student’s name, average test score and letter grade
Stop


TOE chart




Flowchart 










VB.NET code:

Module Module1
    Function readStudentScores(ByRef studentNumber As Integer, ByRef testScores() As Double)
        Console.Write("Enter the student name " + studentNumber.ToString() + ": ")
        Dim name = Console.ReadLine()
        For i As Integer = 0 To 3
            testScores(i) = -1
            While testScores(i) < 0 Or testScores(i) > 100
                Console.Write("Enter the test score " + (i + 1).ToString() + ": ")
                testScores(i) = Double.Parse(Console.ReadLine())
            End While
        Next
        Console.WriteLine()
        Return name
    End Function


    Function calculateAverageScore(ByVal scores() As Double)
        Dim sumAllScores As Double = 0
        For i As Integer = 0 To 3
            sumAllScores += scores(i)
        Next
        Return sumAllScores / 4
    End Function


    Private Function calculateGrade(ByVal avrg As Double) As Char
        If avrg >= 90 Then
            Return "A"
        End If
        If avrg >= 80 Then
            Return "B"
        End If
        If avrg >= 70 Then
            Return "C"
        End If
        If avrg >= 60 Then
            Return "D"
        End If
        Return "F"
    End Function




    Sub Main()
        Dim studentNames(4) As String
        Dim studentGrades(4) As Char


        Dim studentScores1(3) As Double
        Dim studentScores2(3) As Double
        Dim studentScores3(3) As Double
        Dim studentScores4(3) As Double
        Dim studentScores5(3) As Double


        Dim studentScoresAverages(4) As Double


        studentNames(0) = readStudentScores(1, studentScores1)
        studentNames(1) = readStudentScores(2, studentScores2)
        studentNames(2) = readStudentScores(3, studentScores3)
        studentNames(3) = readStudentScores(4, studentScores4)
        studentNames(4) = readStudentScores(5, studentScores5)


        studentScoresAverages(0) = calculateAverageScore(studentScores1)
        studentScoresAverages(1) = calculateAverageScore(studentScores2)
        studentScoresAverages(2) = calculateAverageScore(studentScores3)
        studentScoresAverages(3) = calculateAverageScore(studentScores4)
        studentScoresAverages(4) = calculateAverageScore(studentScores5)


        For i As Integer = 0 To 4
            studentGrades(i) = calculateGrade(studentScoresAverages(i))
        Next
        Console.WriteLine(vbNewLine + "{0,-15}{1,-25}{2,-25}", "Name", "Average test score", "Letter grade")
        For i As Integer = 0 To 4
            Console.WriteLine("{0,-15}{1,-25}{2,-25}", studentNames(i), studentScoresAverages(i), studentGrades(i))
        Next
        Console.ReadLine()
    End Sub


   
End Module

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS