how to create program that will store three student names with corresponding grades for prelim, midterm, and finals. Compute its average.
Imports System.IO
Module Module1
Sub Main()
For i As Integer = 1 To 3
Console.Write("Enter name for student {0}: ", i)
Dim name As String = Console.ReadLine()
Console.Write("Enter prelim for student {0}: ", i)
Dim prelim As Double = Double.Parse(Console.ReadLine())
Console.Write("Enter midterm for student {0}: ", i)
Dim midterm As Double = Double.Parse(Console.ReadLine())
Console.Write("Enter finals for student {0}: ", i)
Dim finals As Double = Double.Parse(Console.ReadLine())
Console.WriteLine("Average: " + computeAverage(prelim, midterm, finals).ToString())
Next
Console.ReadLine()
End Sub
Function computeAverage(ByVal prelim As Double, ByVal midterm As Double, ByVal finals As Double)
Return (prelim + midterm + finals) / 3.0
End Function
End Module
Comments
Leave a comment