#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    **URGENT*** VB Console program to find the min, max and average of 6 grades


    hi everyone, I have been trying to make a program that accepts 6 sudent names and grades (no more), then display them all, plus the average and the min/max. So far, it hasn't went very well. Can someone please tell me where i'm going wrong? also the -999 to exit back to the main menu is faulty.

    Thanks in advance


    Heres my code so far


    Imports System.Math
    Module Module1

    Dim dblGrade(6) As Double
    Dim intCounter As Integer
    Dim strName As String
    Dim strMinGrade As Double



    Sub Main()
    menu()
    End Sub

    Public Sub menu()

    Dim strPause As String
    Dim intOption As Integer

    Do
    'Part 1 Display menu
    System.Console.WriteLine("Menu")
    System.Console.WriteLine("====")
    System.Console.WriteLine("1. Accept Information")
    System.Console.WriteLine("2. Display Data")
    System.Console.WriteLine("3. Exit")
    System.Console.WriteLine("Please select an option (1-3)")
    intOption = System.Console.ReadLine

    'Part 2 if statement based on selection

    If intOption = 1 Then

    'Accept information
    Accept()


    ElseIf intOption = 2 Then
    System.Console.WriteLine("Average = " & Round(AverageGrade(), 2))
    System.Console.WriteLine("Min = " & Round(MinGrade(), 2))
    System.Console.WriteLine("Max = " & Round(maxGrade(), 2))
    System.Console.WriteLine("Names = " & (strName))
    System.Console.WriteLine("Grades = " & (dblGrade(intCounter)))



    ElseIf intOption = 3 Then
    System.Console.WriteLine("Now exiting")



    End If
    'Part 3 loop for when to exit
    Loop While intOption <> 3

    'Pause screen

    System.Console.WriteLine("Press return to exit")
    strPause = System.Console.ReadLine

    End Sub
    Sub Accept()
    Try
    Do




    intCounter = intCounter + 1
    System.Console.WriteLine("Enter the name of the student, -999 to exit")
    strName = System.Console.ReadLine

    intCounter = intCounter + 1
    System.Console.WriteLine("Enter the grade of the student, -999 to exit")
    dblGrade(intCounter) = System.Console.ReadLine

    If (dblGrade(intCounter) < 0 Or dblGrade(intCounter) > 100) And (dblGrade(intCounter) <> -999) Then
    intCounter = intCounter - 1
    System.Console.WriteLine("Invalid Input")

    End If


    Loop While dblGrade(intCounter) <> -999

    Catch ex As Exception
    Console.WriteLine("Error: Invalid input, please enter whole number! " & vbLf & ex.Message)
    End Try
    End Sub



    Function AverageGrade()
    Dim Total, avg As Double
    Dim cnt As Integer
    For cnt = 1 To intCounter - 1
    AverageGrade = Total / 6

    Next

    avg = Total / (intCounter - 1)
    Return avg
    End Function
    Function MinGrade()

    Dim min As Integer
    Dim cnt As Integer

    min = dblGrade(1)
    For cnt = 2 To intCounter - 1
    If dblGrade(cnt) < min Then
    min = dblGrade(cnt)

    End If

    Next
    Return min
    End Function






    Function maxGrade()
    Dim max As Integer
    Dim cnt As Integer

    max = dblGrade(1)
    For cnt = 2 To intCounter - 1

    Next
    If dblGrade(cnt) < max Then

    End If
    max = dblGrade(cnt)
    Return max



    End Function













    End Module
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    99
    Rep Power
    157

    You really are lost aren't you!


    I take it this is a question from your teacher - you are doing a course some where!

    This site is not really about doing your home work, but it is about helping you understand.

    I think you need more help than can be simply typed in here.

    if you want to go through all your mistakes ( misunderstandings openly here on the forum) then fine we can do that

    or you can PM me and we will take you through the process line by line from design to completion

    your choice

    here to help
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    18
    Rep Power
    0

    Talking Massive overkill


    Just use a spreadsheet

IMN logo majestic logo threadwatch logo seochat tools logo