I'm stuck on my homework trying to deal with arrays of structs. The prof is terrible and just reads off slides from another prof and talks about his weekend. Heres what we have to do:
You have been hired as a programmer for Super Sales Company. You are being asked to write a sales report program. You should implement this program as an array of structures (set MAXARRAY = 39). There will not be 40 items, so you must keep track of how many items you have read in. The format for each line in the file commiss.dat contains an employee’s first name, last name, employee id number and the amount of sales for each weekday. This file is on VSpace in the resources. The following is a sample of the input file:
John Fredricks 102 70.00 90.00 104.00 305.00 408.00
Jane Williams 104 89.00 105.00 70.00 400.00 207.00
Scott Howard 103 100.00 100.00 100.00 100.00 100.00
You should create a report which prints out the employee’s name, id number, 5 daily sales, total sales and average sales. Here is a sample of the report you should create:
Super Sales Associate
Weekly Sales Report
Name ID Mon Tue Wed Thu Fri Total Average
John Fredricks 102 70.00 90.00 104.00 305.00 408.00 977.00 195.40
Jane Williams 104 89.00 105.00 70.00 400.00 207.00 871.00 174.20
Scott Howard 103 100.00 100.00 100.00 100.00 100.00 500.00 100.00
Fred Wilkes 105 189.00 207.00 306.00 99.00 203.00 1004.00 200.80
You may find it easier to create a location for the total and average columns within the struct definition. I know that there are other ways to do this program, but you must use an array of structs since your next assignment will be a modification of this assignment.
My problem is that I don't know how to make it so I can read string by string. I only know how to read by lines. So my codes something like:
Structure EmployeeInfo Dim FirstName As String Dim LastName As String Dim ID As String Dim Mon As Double Dim Tue As Double Dim Wed As Double Dim Thu As Double Dim Fri As Double End Structure Dim Data As EmployeeInfo Dim sr As IO.StreamReader = IO.File.OpenText("commiss.txt")
and then all I know how to do is Data.FristName = sr.ReadLine which stores the first line of data into Data.FirstName ....which I only want the first name.
So i'm wondering if theres something along the lines of Data.Firstname, Data.SecondName (etc) = sr.ReadLine? Something along the lines of the equivialnt to C++ like
infile >> Data.FirstName >> Data.SecondName >> Data.ID etc.