Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads data from a data file called final.dat. The data file

ID: 3716039 • Letter: W

Question

Write a program that reads data from a data file called final.dat. The data file contains the following information

Name salary age

The program should store the information into a list. You are free to use any type of container (parallel arrays, array or struct, linked list, STL list) - 40 points.

After storing the information into the list, the program should do the following:

Print the list out with an appropriate message before printing the list. -20 pts

Print the average age of everyone in the list. - 20 pts

Print the name of the oldest person in the list. - 20 pts

Sort the list in increasing order by age. - 10 pts

Print the list after it has been sorted. - 10 pts

Proper identications - 30 pts

again please make a data file called final.dat!!!

Explanation / Answer

using System;

using System.IO;

class MyStream

{

    private const string FILE_NAME = "Test.data";

    public static void Main()

    {

        if (File.Exists(FILE_NAME))

        {

            Console.WriteLine("{0} already exists!", FILE_NAME);

            return;

        }

        using (FileStream fs = new FileStream(FILE_NAME, FileMode.CreateNew))

        {

            using (BinaryWriter w = new BinaryWriter(fs))

            {

                for (int i = 0; i < 11; i++)

                {

                    w.Write(i);

                }

            }

        }

       

        using (FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read))

        {

            using (BinaryReader r = new BinaryReader(fs))

            {

                for (int i = 0; i < 11; i++)

                {

                    Console.WriteLine(r.ReadInt32());

                }

            }

        }

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote