I'm trying to Write a Console application that will read in an unknown number of integers (up to 100) from data.txt, a comma-delimited text file in the current directory. The program should show the numbers as they are given in the file, and it should also show the numbers in ascending (sorted) order. (Sort by value). The output should look like the figure below.
A sample data file is given, but the testing numbers will be different. This file should be in the default directory (bin).
Add a console.readline() at the end of your code to keep the console window open. Also, be sure to add a console.writeline() at the top to print your name.
However I have no idea what to do to get the text file to load in. So far I have this
Sub Main() Console.WriteLine("Bubble Sort by Ian Pinholster") Dim array(100) As Int16 Dim n, c, d, swap As Int16 Console.WriteLine("Enter Number of Elements") n = Convert.ToInt16(Console.ReadLine()) Console.Write(Constants.vbCrLf) Console.WriteLine("Enter " + n.ToString() + " integers") For c = 0 To n - 1 array(c) = Convert.ToInt16(Console.ReadLine()) Next For c = 0 To n - 2 For d = 0 To n - c - 2 If (array(d) > array(d + 1)) Then swap = array(d) array(d) = array(d + 1) array(d + 1) = swap End If Next Next Console.Write(Constants.vbCrLf) Console.WriteLine("Sorted list in ascending order: ") For c = 0 To n - 1 Console.WriteLine(array(c)) Next Console.ReadKey() End Sub
Any help on where to go would be awesome