VB.Net I need help!!!

Discussion in 'OT Technology' started by vonoventwin, Jan 31, 2005.

  1. vonoventwin

    vonoventwin New Member

    Oct 25, 2004
    Likes Received:
    Warner Robins, GA
    Here is what my instructor told us to do:

    Project Type
    •This project is to use a console application.

    •Prompt for an input file name. Input is from a text file containing integer numbers, one number per line. The file will contain no more than 50 numbers. The file will be "clean": no embedded errors, illegal characters, etc.
    •Your program should read this file into an array.

    •Yours to figure out

    Output (one per line formatted so it is easy to read)
    •Standard Deviation

    Input File Format
    The file is a text file and contains only integer values. Each number is on a separate line in the file. The total number of integers in the file can vary, but will not exceed 50. The example function supplied below will illustrate how integers can be read from a text file.

    Here is what I know and don't know:

    Maximum: the highest number in the input file
    Minimum: the lowest number in the input file
    Mean: average m=(a+b+c+d+e)/5
    Mode: the # or range of numbers that occurs most frequently
    Median : I HAVE NO IDEA
    Standard Deviation: Square root of: Sigma(x-a)power of 2/n

    Where x is an individual number; a is the mean; and n is the number of values

    Here's the function that will read the input file:
    Function ReadInputFile( ByRef ar() as Integer, Optional fileName as string="project1.txt") as integerDim n as integer = 0 'holds the number of elements read from fileTryDim fs as New System.IO.StreamReader(filename)Dim line as stringDoline = fs.ReadLine()if not line is nothingar(n) = convert.ToInt16(line)n+=1end ifLoop Until line Is Nothingfs.Close()return n 'returns number of elements read into the arrayCatch E As Exception'Let the user know what went wrongConsole.WriteLine("The file could not be read:")Console.WriteLine(E.Message)End Tryreturn n 'number of elements read from fileEnd Function

Share This Page