static void Writer4(ref StreamWriter write, ref List <SuperBowl> listOfSuperBowls)
        {
            write.WriteLine("\nPlayers that have been named MVP more than once: \n");
            var MVPQuery = from superBowl in listOfSuperBowls
                           group superBowl by superBowl.MVP into MVPGroup
                           orderby MVPGroup.Count() descending
                               where MVPGroup.Count() > 1
                           select MVPGroup;

            foreach (var mvp in MVPQuery)
            {
                write.WriteLine(mvp.Key);
                foreach (var player in mvp)
                {
                    write.WriteLine(player.MVPWriter());
                }
                write.WriteLine("\n");
            }
        }
Beispiel #2
0
        public static void MVP(List <SuperBowlWinner> SuperBowlWinners, StreamWriter Writer)
        {
            var TopMVP =
                from i in SuperBowlWinners
                group i by i.MVP into MVPGroup
                where MVPGroup.Count() > 2
                orderby MVPGroup.Count() descending
                select MVPGroup;

            Writer.WriteLine();
            Writer.WriteLine("         Winningest MVP's");

            foreach (var e in TopMVP)
            {
                Writer.WriteLine(e.Key);
                foreach (var i in e)
                {
                    Writer.WriteLine("MVP: {0,-15} Winning Team: {1,-20} Losing Team: {2,-20}", i.MVP, i.WinningTeam, i.LosingTeam);
                }
                Writer.WriteLine();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to NFL Summary Program! Press 'enter' to continue\n");
            Console.WriteLine("Please enter the path (without file name) you would like to read from and then press 'enter'");
            Console.WriteLine("Warning: If file directory doesn't contain a file called Super_Bowl_Project.csv no output file will be created");

            string PATH = Console.ReadLine();

            if (Directory.Exists(PATH))
            {
                Console.WriteLine("Directory exists");
            }
            else
            {
                Console.WriteLine("Directory Doesn't exist, Exiting Program");
                System.Environment.Exit(1);
            }
            //For mstring PATH = @"C:\Users\steantc\Documents\CWEB2010\Project2\super-bowl-data-analytics-program-project-2-Steantc\Super_Bowl_Project.csv";
            string line;

            string[]       data;
            List <SB_Info> sbList = null;

            try
            {
                FileStream   input = new FileStream(PATH + "\\Super_Bowl_Project.csv", FileMode.Open, FileAccess.Read);
                StreamReader read  = new StreamReader(input);
                line   = read.ReadLine();
                sbList = new List <SB_Info>();
                while (!read.EndOfStream)
                {
                    data = read.ReadLine().Split(',');
                    sbList.Add(new SB_Info(data[0], data[1], Convert.ToInt32(data[2]), data[3], data[4], data[5], Convert.ToInt32(data[6]),
                                           data[7], data[8], data[9], Convert.ToInt32(data[10]), data[11], data[12], data[13], data[14]));
                }
                read.Close();
                input.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("please choose a file path (without file name) and press 'enter'");
            string filePath = Console.ReadLine();

            if (Directory.Exists(filePath))
            {
                Console.WriteLine("your file Super_Bowl_Info awaits");
                Console.WriteLine("Press 'enter' to continue");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Directory Doesn't exist, Exiting Program");
                System.Environment.Exit(1);
            }

            using (StreamWriter writer = new StreamWriter(filePath + "\\Super_Bowl_Info.txt", false))
            {
                Console.WriteLine("A summary of Super Bowl information\n");
                writer.WriteLine("A summary of Super Bowl information\n");
                //List of superbowl winners
                Console.WriteLine("List of all Super Bowl Winners\n");
                writer.WriteLine("List of all Super Bowl Winners\n");
                sbList.ForEach(x => Console.WriteLine($"The Winner was {x.Winner} Year: {x.Date} Winning QB: {x.QB_Winner} Coach: {x.Coach_Winner} MVP: {x.MVP} Difference in Points = {x.Winning_Pts - x.Losin_Pts}             "));//extra space for formatting
                sbList.ForEach(x => writer.WriteLine($"The Winner was {x.Winner} Year: {x.Date} Winning QB: {x.QB_Winner} Coach: {x.Coach_Winner} MVP: {x.MVP} Difference in Points = {x.Winning_Pts - x.Losin_Pts}             "));

                //List of the top 5 attended superbowls
                Console.WriteLine("\nThe Top 5 attended Super Bowls\n");
                writer.WriteLine("\nThe Top 5 attended Super Bowls\n");
                var top5Query = (from SB_Info in sbList
                                 orderby SB_Info.Attendance descending
                                 select SB_Info).Take(5);
                top5Query.ToList().ForEach(s => Console.WriteLine($"{s.Attendance} attended Super Bowl {s.SB} on {s.Date}  {s.Winner} won  {s.Loser} lost. Game was held at {s.City}, {s.State} in {s.Stadium}"));
                top5Query.ToList().ForEach(s => writer.WriteLine($"{s.Attendance} attended Super Bowl {s.SB} on {s.Date}  {s.Winner} won  {s.Loser} lost. Game was held at {s.City}, {s.State} in {s.Stadium}"));

                //State that hosted the most super bowls
                var stateMostQuery = (from SB_Info in sbList
                                      group SB_Info by SB_Info.State into nestedQuery
                                      orderby nestedQuery.Count() descending
                                      select nestedQuery).First().Count();

                var qryState = from SB_Info in sbList
                               group SB_Info by SB_Info.State into stateGroups
                               where stateGroups.Count() == stateMostQuery
                               select stateGroups;
                foreach (var outerGroup in qryState)
                {
                    Console.WriteLine($"\nThe state that has hosted the most Super Bowls is {outerGroup.Key}: \n");
                    writer.WriteLine($"\nThe state that has hosted the most superbowls is {outerGroup.Key}: \n");
                    foreach (var MostGroup in qryState)
                    {
                        foreach (var detail in MostGroup)
                        {
                            Console.WriteLine($"Super Bowl {detail.SB} { detail.City}, {detail.State} at {detail.Stadium}");
                            writer.WriteLine($"Super Bowl {detail.SB} { detail.City}, {detail.State} at {detail.Stadium}");
                        }
                    }
                }

                //MPV Winners
                Console.WriteLine("\nThe Players who have earned MVP more than once are:");
                writer.WriteLine("\nThe Players who have earned MVP more than once are:");
                var mvpQuery = from SB_Info in sbList
                               group SB_Info by SB_Info.MVP into MVPGroup
                               where MVPGroup.Count() > 1
                               orderby MVPGroup.Key
                               select MVPGroup;
                foreach (var MVPGroup in mvpQuery)
                {
                    Console.WriteLine($"\n{MVPGroup.Key} with {MVPGroup.Count()}.");
                    writer.WriteLine($"\n{MVPGroup.Key} with {MVPGroup.Count()}.");
                    foreach (var SB_Info in MVPGroup)
                    {
                        Console.WriteLine($"The winner at Super Bowl {SB_Info.SB} was the {SB_Info.Winner} and the loser was the {SB_Info.Loser}");
                        writer.WriteLine($"The winner at Super Bowl {SB_Info.SB} was the {SB_Info.Winner} and the loser was the {SB_Info.Loser}");
                    }
                }

                //Coach(s) That Lost the most super bowls
                Console.WriteLine("\nThe coaches that have lost the most Super Bowls are:\n");
                writer.WriteLine("\nThe coaches that have lost the most Super Bowls are:\n");
                var CoachLostQuery = from SB_Info in sbList
                                     .GroupBy(SB_Info => SB_Info.Coach_Loser)
                                     select new
                {
                    SB_Info.Key,
                    Most = SB_Info.Count()
                };
                foreach (var SB_Info in CoachLostQuery)
                {
                    if (SB_Info.Most == CoachLostQuery.Max(x => x.Most))
                    {
                        Console.WriteLine($"{SB_Info.Key} has lost {SB_Info.Most}");
                        writer.WriteLine($"{SB_Info.Key} has lost {SB_Info.Most}");
                    }
                }

                //Coach(s) That won the most super bowls
                Console.WriteLine("\nThe coaches that have won the most Super Bowls are:\n");
                writer.WriteLine("\nThe coaches that have won the most Super Bowls are:\n");
                var CoachWonQuery = from SB_Info in sbList
                                    .GroupBy(SB_Info => SB_Info.Coach_Winner)
                                    select new
                {
                    SB_Info.Key,
                    Most = SB_Info.Count()
                };
                foreach (var SB_Info in CoachWonQuery)
                {
                    if (SB_Info.Most == CoachWonQuery.Max(x => x.Most))
                    {
                        Console.WriteLine($"{SB_Info.Key} has won {SB_Info.Most}");
                        writer.WriteLine($"{SB_Info.Key} has won {SB_Info.Most}");
                    }
                }

                //Team(s) that lost the most super bowls
                Console.WriteLine("\nThe teams that have lost the most Super Bowls are:\n");
                writer.WriteLine("\nThe teams that have lost the most Super Bowls are:\n");
                var TeamLostQuery = from SB_Info in sbList
                                    .GroupBy(SB_Info => SB_Info.Loser)
                                    select new
                {
                    SB_Info.Key,
                    Most = SB_Info.Count()
                };
                foreach (var SB_Info in TeamLostQuery)
                {
                    if (SB_Info.Most == TeamLostQuery.Max(x => x.Most))
                    {
                        Console.WriteLine($"{SB_Info.Key} have Lost {SB_Info.Most}");
                        writer.WriteLine($"{SB_Info.Key} have Lost {SB_Info.Most}");
                    }
                }

                //Team(s) that won the most super bowls
                Console.WriteLine("\nThe teams that have won the most Super Bowls are:\n");
                writer.WriteLine("\nThe teams that have won the most Super Bowls are:\n");
                var TeamWonQuery = from SB_Info in sbList
                                   .GroupBy(SB_Info => SB_Info.Winner)
                                   select new
                {
                    SB_Info.Key,
                    Most = SB_Info.Count()
                };
                foreach (var SB_Info in TeamWonQuery)
                {
                    if (SB_Info.Most == TeamWonQuery.Max(x => x.Most))
                    {
                        Console.WriteLine($"{SB_Info.Key} have won {SB_Info.Most}");
                        writer.WriteLine($"{SB_Info.Key} have won {SB_Info.Most}");
                    }
                }

                //Greatest point differnce
                var pointDifQuery = (from SB_Info in sbList
                                     let dif = SB_Info.Winning_Pts - SB_Info.Losin_Pts
                                               group new { SB_Info.SB } by dif into SBgroup
                                     orderby SBgroup.Key
                                     select SBgroup);
                foreach (var SBgroup in pointDifQuery)
                {
                    if (SBgroup.Key == pointDifQuery.Max(x => x.Key))
                    {
                        foreach (var SB_Info in SBgroup)
                        {
                            Console.WriteLine($"\nThe largest Point difference was { SBgroup.Key} at SuperBowl {SB_Info.SB}");
                            writer.WriteLine($"\nThe largest Point difference was { SBgroup.Key} at SuperBowl {SB_Info.SB}");
                        }
                    }
                }

                //Average Attendance for all Super Bowls
                var averageQuery = (from SB_Info in sbList
                                    select SB_Info.Attendance).Average();
                double average = averageQuery;
                Console.WriteLine($"\nAverage attendance for all Super Bowls is {average}\n");
                writer.WriteLine($"\nAverage attendance for all Super Bowls is {average}\n");
            }
        }
Beispiel #4
0
        public static void MostMVP(ref List <SBList1> ListAdd, StreamWriter FileWrite)
        {
            FileWrite.WriteLine("Most MVP's");
            FileWrite.WriteLine();
            var mvpList = (from order in ListAdd group order by order.MVP into MVPGroup where MVPGroup.Count() > 2 select MVPGroup.First()).ToList();

            for (var x = 0; x < mvpList.Count(); x++)
            {
                FileWrite.WriteLine($"MVP: {mvpList[x].MVP}");
                FileWrite.WriteLine($"Team that won: {mvpList[x].tWinner}");
                FileWrite.WriteLine($"Team that lost: {mvpList[x].tLoser}");
                FileWrite.WriteLine();
            }
            FileWrite.WriteLine("----- End of Most MVP's");
            FileWrite.WriteLine();
            return;
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            //Reading from a file
            //Declaring variables
            FileStream   input;
            StreamReader read;
            string       primingValue;

            string[] sbData;
            string   csvPATH = "";
            string   txtPATH = "";

            //Program Introduction
            Console.WriteLine("Welcome to the Superbowl CSV file reader.");
            Console.WriteLine("This Program will read the data from the CSV file and write it to a TXT file.\n");

            //User defines the PATH to the csv
            Console.WriteLine("Where do you want to read the csv file from?\n");
            Console.WriteLine("for example:\nC:\\Users\\Jake\\Documents\\College\\SENG Semester 2\\Advanced Programming\\Projects\\Project 2\\Project_Two\\Super_Bowl_Project.csv\n");
            Console.WriteLine("Input the PATH to the CSV File:");
            csvPATH = @Console.ReadLine();
            Console.Clear();

            //User defines the PATH to the txt
            Console.WriteLine("Where do you want to read the csv file from?\n");
            Console.WriteLine("for example:\nC:\\Users\\Jake\\Documents\\College\\SENG Semester 2\\Advanced Programming\\Projects\\Project 2\\Project_Two\\Super_Bowl_Project.txt\n");
            Console.WriteLine("Input the PATH to the TXT File:");
            txtPATH = @Console.ReadLine();
            Console.Clear();

            try
            {
                //declaring a file stream to write to the text file with the superbowl data
                FileStream   newfile = new FileStream(txtPATH, FileMode.Create, FileAccess.Write);
                StreamWriter outfile = new StreamWriter(newfile);

                input        = new FileStream(csvPATH, FileMode.Open, FileAccess.Read);
                read         = new StreamReader(input);
                primingValue = read.ReadLine();
                List <SuperBowl> sbDataList = new List <SuperBowl>(); //declaring superbowl data list

                //Establishing a looping structure to read in all the superbowl data
                while (!read.EndOfStream)
                {
                    sbData = read.ReadLine().Split(',');  //reads in each element between each comma and splits the comma off
                    SuperBowl sb = new SuperBowl(sbData); //each element of the list will be called sb
                    sbDataList.Add(sb);                   //adds a superbowl to the list
                    //Console.WriteLine(sbDataList[sbDataList.Count - 1]); //used to insure that the data is populating the list
                }

                read.Dispose();
                input.Dispose();

                //Below outputs the list of the winning teams
                Console.WriteLine("            List of Winning Teams");
                outfile.WriteLine("            List of Winning Teams");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //invoking the print winner function in a foreach
                foreach (SuperBowl sb in sbDataList)
                {
                    Console.WriteLine(sb.printWinner());
                }

                foreach (SuperBowl sb in sbDataList)
                {
                    outfile.WriteLine(sb.printWinner());
                }

                //Below outputs the list of the top attended superbowl counts
                Console.WriteLine("          Top 5 Attended Superbowls");
                outfile.WriteLine("          Top 5 Attended Superbowls");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                var attendanceQuery = (from sb in sbDataList orderby sb.Attendance descending select sb).ToList <SuperBowl>().Take(5); //selects 5 superbowls by top attendance from the superbowl data list and pust them into an attendance query list

                //For each element in the attendance query write the date, winning team, losing team, city, state, and stadium
                //This code was influenced off of LeAnn Simonson and Sarah Fox
                attendanceQuery.ToList <SuperBowl>().ForEach(x => Console.WriteLine($"1. The date the team won: {x.Date}\n2. The winning team: {x.winningTeam}\n3. The losing team: {x.losingTeam}\n" +
                                                                                    $"4. The city: {x.City}\n5. The state: {x.State}\n6. The stadium: {x.Stadium}\n7. The attendance: {x.Attendance}\n"));

                attendanceQuery.ToList <SuperBowl>().ForEach(x => outfile.WriteLine($"1. The date the team won: {x.Date}\n2. The winning team: {x.winningTeam}\n3. The losing team: {x.losingTeam}\n" +
                                                                                    $"4. The city: {x.City}\n5. The state: {x.State}\n6. The stadium: {x.Stadium}\n7. The attedance: {x.Attendance}\n"));

                //Below outputs the state that hosted the most superbowls
                //This section and the MVP section contain adapted code originally from LeAnn Simonson
                Console.WriteLine("    State That Hosted The Most Superbowls");
                outfile.WriteLine("    State That Hosted The Most Superbowls");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                var hostQueryCount = (from sb in sbDataList                                                            //defining a query count variable that is used to make a descending list
                                      group sb by sb.State into nestedQuery                                            //creates a group of state data and puts it into a nested query
                                      orderby nestedQuery.Count() descending                                           //orders the list
                                      select nestedQuery).First().Count();                                             //takes the count of the first element in nestedQuery (the state that hosted the most superbowls)

                var hostCount = (from sb in sbDataList                                                                 //defining a host count variable that considers each superbowl(sb) in the superbowl data list
                                 group sb by sb.State into hostGroup                                                   //creates a group of state data and puts it into host group
                                 where hostGroup.Count() == hostQueryCount                                             //adds a condition to the list where the only element it contains can be equal to the most hosted count
                                 select hostGroup).Take(1);                                                            //takes the one element in the list

                foreach (var sb in hostCount)                                                                          //iterates through the list (even though it's just one element)
                {
                    Console.WriteLine($"{sb.Key} hosted the most superbowls. They hosted {sb.Count()} superbowls.\n"); //writes the state and count to the terminal
                    outfile.WriteLine($"{sb.Key} hosted the most superbowls. They hosted {sb.Count()} superbowls.\n"); //writes the state and count to the file
                    foreach (var info in sb)                                                                           //iterates through the info attached to the sb element and outputs the city, state, stadium, and date
                    {
                        Console.WriteLine($"1. City: {info.City}");                                                    //using methods to pull data from a superbowl
                        outfile.WriteLine($"1. City: {info.City}");
                        Console.WriteLine($"2. State: {info.State}");
                        outfile.WriteLine($"2. State: {info.State}");
                        Console.WriteLine($"3. Stadium: {info.Stadium}");
                        outfile.WriteLine($"3. Stadium: {info.Stadium}");
                        Console.WriteLine($"4. Date: {info.Date}\n");
                        outfile.WriteLine($"4. Date: {info.Date}\n");
                    }
                }

                //Below outputs players that won MVP for than once as well as their team and the team they beat
                Console.WriteLine("List of Players That Won Mvp More Than 1 Time");
                outfile.WriteLine("List of Players That Won Mvp More Than 1 Time");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                var MVPCount = from sb in sbDataList            //defining an MVPCount variable that considers each superbowl(sb) in the superbowl data list
                               group sb by sb.MVP into MVPGroup //creates a group of MVP data to be counted
                               where MVPGroup.Count() > 1       //only adds the MVP to the group if the player was MVP more than once
                               orderby MVPGroup.Key             //orders the list
                               select MVPGroup;                 //returns the ordered list of MVPs in a list format

                foreach (var sb in MVPCount)
                {
                    Console.WriteLine($"{sb.Key} won MVP {sb.Count()} times\n");         //writes the MVP and amount of times they were MVP
                    outfile.WriteLine($"{sb.Key} won MVP {sb.Count()} times\n");
                    foreach (var info in sb)                                             //iterates through the info attached to the sb element(MVP) and outputs the winning team, team they beat, and the date the superbowl took place.
                    {
                        Console.WriteLine($"1. Their winning team: {info.winningTeam}"); //using methods to pull data from a superbowl
                        outfile.WriteLine($"1. Their winning team: {info.winningTeam}");
                        Console.WriteLine($"2. The team they beat: {info.losingTeam}");
                        outfile.WriteLine($"2. The team they beat: {info.losingTeam}");
                        Console.WriteLine($"3. Superbowl took place: {info.Date}\n");
                        outfile.WriteLine($"3. Superbowl took place: {info.Date}\n");
                    }
                    Console.WriteLine("\n");
                    outfile.WriteLine("\n");
                }

                //Below outputs the coach that lost the most superbowls
                Console.WriteLine("     Coach That Lost The Most Superbowls  ");
                outfile.WriteLine("     Coach That Lost The Most Superbowls  ");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //Defining a query count variable that is used to make a descending list to determine highest loss count.
                //It creates a group of losing coach data and puts it into a nested query, orders the list, and takes the
                //count of the first element in nestedQuery (the coach that lost the most superbowls).
                var highestLossCount = (from sb in sbDataList
                                        group sb by sb.losingCoach
                                        into nestedQuery
                                        orderby nestedQuery.Count() descending
                                        select nestedQuery).First().Count();

                //defining a losing coach query that is designed to take the coach that lost the most by using a condition that
                //was found in the nested query. From there, the coaches that lost the most are selected and added to an array
                var losingCoachQuery = (from sb in sbDataList
                                        group sb by sb.losingCoach
                                        into losingCoachGroup
                                        where losingCoachGroup.Count() == highestLossCount
                                        select losingCoachGroup.Key).ToArray();

                for (var x = 0; x < losingCoachQuery.Length; x++)
                {
                    Console.WriteLine($"- {losingCoachQuery[x]} lost the most superbowls\n");
                    outfile.WriteLine($"- {losingCoachQuery[x]} lost the most superbowls\n");
                }
                Console.WriteLine("\n");
                outfile.WriteLine("\n");

                //Below outputs the coach that won the most superbowls
                //////
                Console.WriteLine("     Coach That Won The Most Superbowls  ");
                outfile.WriteLine("     Coach That Won The Most Superbowls  ");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //The same process as the most losses coach section is used for this query manipulation.
                var highestWinCount = (from sb in sbDataList
                                       group sb by sb.winningCoach
                                       into nestedQuery
                                       orderby nestedQuery.Count() descending
                                       select nestedQuery).First().Count();

                var winningCoachQuery = (from sb in sbDataList
                                         group sb by sb.winningCoach
                                         into winningCoachGroup
                                         where winningCoachGroup.Count() == highestWinCount
                                         select winningCoachGroup.Key).ToArray();

                for (var x = 0; x < winningCoachQuery.Length; x++)
                {
                    Console.WriteLine($"- {winningCoachQuery[x]} won the most superbowls\n");
                    outfile.WriteLine($"- {winningCoachQuery[x]} won the most superbowls\n");
                }
                Console.WriteLine("\n");
                outfile.WriteLine("\n");

                //Below outputs the team that won the most superbowls
                //////
                Console.WriteLine("      Team That Won The Most Superbowls");
                outfile.WriteLine("      Team That Won The Most Superbowls");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //The same process as the most losses coach section is used for this query manipulation.
                var teamHighestWinCount = (from sb in sbDataList
                                           group sb by sb.winningTeam
                                           into nestedQuery
                                           orderby nestedQuery.Count() descending
                                           select nestedQuery).First().Count();

                var winningTeamQuery = (from sb in sbDataList
                                        group sb by sb.winningTeam
                                        into winningTeamGroup
                                        where winningTeamGroup.Count() == teamHighestWinCount
                                        select winningTeamGroup.Key).ToArray();

                for (var x = 0; x < winningTeamQuery.Length; x++)
                {
                    Console.WriteLine($"- {winningTeamQuery[x]} won the most superbowls\n");
                    outfile.WriteLine($"- {winningTeamQuery[x]} won the most superbowls\n");
                }
                Console.WriteLine("\n");
                outfile.WriteLine("\n");

                //Below outputs the team that lost the most superbowls
                //////
                Console.WriteLine("     Team That Lost The Most Superbowls");
                outfile.WriteLine("     Team That Lost The Most Superbowls");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //The same process as the most losses coach section is used for this query manipulation.
                var teamHighestLossCount = (from sb in sbDataList
                                            group sb by sb.losingTeam
                                            into nestedQuery
                                            orderby nestedQuery.Count() descending
                                            select nestedQuery).First().Count();

                var losingTeamQuery = (from sb in sbDataList
                                       group sb by sb.losingTeam
                                       into losingTeamGroup
                                       where losingTeamGroup.Count() == teamHighestLossCount
                                       select losingTeamGroup.Key).ToArray();

                for (var x = 0; x < losingTeamQuery.Length; x++)
                {
                    Console.WriteLine($"- {losingTeamQuery[x]} lost the most superbowls\n");
                    outfile.WriteLine($"- {losingTeamQuery[x]} lost the most superbowls\n");
                }
                Console.WriteLine("\n");
                outfile.WriteLine("\n");

                //Below outputs the superbowl that had the greatest point difference
                Console.WriteLine("  Superbowl with Greatest Point Difference");
                outfile.WriteLine("  Superbowl with Greatest Point Difference");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //declaring an empty list to place the point differences
                var pointDifferences = new List <int>();

                //for each superbowl element in the superbowl data list, add the point differences associated with the superbowl to the list
                foreach (var sb in sbDataList)
                {
                    pointDifferences.Add(sb.pointDifference());
                }

                //delcaring a greatest point difference variable and making it equal to the max point difference in the point differences list
                var greatestPointDifference = pointDifferences.Max();

                //for each superbowl element in the superbowl data list, write to the file and
                //console only if the point difference is equal to the greatest point difference
                foreach (var sb in sbDataList)
                {
                    if (sb.pointDifference() == greatestPointDifference)
                    {
                        Console.WriteLine($"- Superbowl {sb.SB} has the greatest point difference of {sb.pointDifference()}");
                        outfile.WriteLine($"- Superbowl {sb.SB} has the greatest point difference of {sb.pointDifference()}");
                    }
                }
                Console.WriteLine("\n");
                outfile.WriteLine("\n");

                //Below outputs the average attendance
                Console.WriteLine("     Average Attendance of All Superbowls");
                outfile.WriteLine("     Average Attendance of All Superbowls");
                Console.WriteLine("---------------------------------------------\n");
                outfile.WriteLine("---------------------------------------------\n");

                //declaring integers to invoke an attendance function
                int totalAttendance = 0;
                int avgAttendance;
                int count = 0;

                //adds the attendance onto the total attendance and increases the
                //count by one for each superbowl element in superbowl data list
                foreach (var sb in sbDataList)
                {
                    totalAttendance = totalAttendance + sb.Attendance;
                    count           = count + 1;
                }
                //simple average attendance function
                avgAttendance = totalAttendance / count;

                Console.WriteLine($"Average Attendance: {avgAttendance}");
                outfile.WriteLine($"Average Attendance: {avgAttendance}");

                Console.WriteLine("\n");
                outfile.WriteLine("\n");

                //End message and file closing
                outfile.Close(); //closes the outfile (this fixes data stream issues as well)
                Console.WriteLine("The data displayed above has been written to the TXT file");
            } //end of try

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        static void Main(string[] args)
        {
            List <winningteam> Team     = new List <winningteam>();
            string             primer   = "";
            string             textFile = "";
            string             path     = "";

            Console.WriteLine("Enter program by entering name or enter x to exit");

            primer = Convert.ToString(Console.ReadLine());//using continuous loop, x to exit loop

            if (primer != "x")
            {
                Console.WriteLine($"{primer} What file path do you want to read? (.csv)");
                textFile = @Console.ReadLine();
                Console.WriteLine(textFile);

                Console.WriteLine("\nWhat file path do you want it to be written in (.txt)");
                path = @Console.ReadLine();
                Console.WriteLine(path);

                try
                {
                    if (File.Exists(textFile))
                    {
                        using (StreamReader file = new StreamReader(textFile))

                        {
                            int    counter = 0;
                            string ln;
                            Regex  CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

                            while ((ln = file.ReadLine()) != null)

                            {
                                string[] col = CSVParser.Split(ln);

                                {
                                    if (counter > 0)

                                    {
                                        winningteam team = new winningteam(col[0], col[1], col[2], col[3], col[4], col[5], col[6], col[7], col[8], col[9], col[10], col[11], col[12], col[13], col[14]);
                                        Team.Add(team);
                                    }
                                    counter++;
                                }
                            }
                            file.Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("error message: {0}", e.ToString());
                }
                //super bowl write winners

                using (StreamWriter file = File.CreateText(path))

                {
                    Console.WriteLine("\n\nSuper Bowl Winners\n");
                    file.WriteLine("\n\nSuper Bowl Winners\n");

                    file.WriteLine("Team name" + "\t\t" + "Year won" + "\t\t" + "Winning QB" + "\t\t" + "Winning Coach" + "\t\t" + "MVP" + "\t\t" + "Point Difference");
                    Console.WriteLine("Team name" + "\t\t" + "Year won" + "\t\t" + "Winning QB" + "\t\t" + "Winning Coach" + "\t\t" + "MVP" + "\t\t" + "Point Difference");


                    foreach (winningteam item in Team)
                    {
                        file.WriteLine(item.Winner + "\t\t" + item.Sdate.Year + "\t\t" + item.QBWinner + "\t\t" + item.CoachWinner + "\t\t" + item.MVP + "\t\t" + (item.WinningPts - item.LosingPts));
                        Console.WriteLine(item.Winner + "\t\t" + item.Sdate.Year + "\t\t" + item.QBWinner + "\t\t" + item.CoachWinner + "\t\t" + item.MVP + "\t\t" + (item.WinningPts - item.LosingPts));
                    }

                    file.Close();


                    //top 5
                    using (StreamWriter bfile = File.AppendText(path))

                    {
                        bfile.WriteLine("Attendance" + "\t\t" + "Year of Win" + "\t\t" + "Winning Team" + "\t\t" + "Losing Team" + "\t\t" + "City" + "\t\t" + "State" + "\t\t" + "Stadium");
                        Console.WriteLine("Attendance" + "\t\t" + "Year of Win" + "\t\t" + "Winning Team" + "\t\t" + "Losing Team" + "\t\t" + "City" + "\t\t" + "State" + "\t\t" + "Stadium");

                        bfile.WriteLine("\n\nTop 5 attended Super Bowls\n");
                        Console.WriteLine("\n\nTop 5 attended Super Bowls\n");


                        var qryTopFive = (from item in Team
                                          orderby item.Attendance descending
                                          select item).Take(5);

                        qryTopFive.ToList().ForEach(s => bfile.WriteLine(s.Attendance + "\t" + s.Sdate.Year + "\t" + s.Winner + "\t" + s.Loser + "\t" + s.City + "\t" + s.State + "\t" + s.Stadium));
                        qryTopFive.ToList().ForEach(s => Console.WriteLine(s.Attendance + "\t" + s.Sdate.Year + "\t" + s.Winner + "\t" + s.Loser + "\t" + s.City + "\t" + s.State + "\t" + s.Stadium));
                    }

                    file.Close();


                    //Generate a list of states that hosted the most super bowls
                    using (StreamWriter cfile = File.AppendText(path))

                    {
                        cfile.WriteLine("\n\nStatistics on States where SuperBowls were hosted\n");
                        Console.WriteLine("\n\n Statistics on States where SuperBowls were hosted\n");
                        var qryState = from stateRecord in Team
                                       group stateRecord by new
                        {
                            stateRecord.State
                        } into stateGroups
                        from cityGroups in
                        (from city in stateGroups
                         orderby city.City, city.Sdate.Year descending, city.Stadium
                         group city by new { city.City })
                        orderby stateGroups.Key.State
                        group cityGroups by new { stateGroups.Key.State };                //group cities and states


                        foreach (var outerGroup in qryState)
                        {
                            Console.WriteLine($"{ outerGroup.Key.State }: ");
                            cfile.WriteLine($"{ outerGroup.Key.State }: ");
                            foreach (var detail in outerGroup)
                            {
                                Console.WriteLine($"\t{ detail.Key.City }");
                                cfile.WriteLine($"\t{ detail.Key.City }");

                                int v_count = 0;
                                foreach (var city in detail)

                                {
                                    Console.WriteLine($"\t\tIn {city.Sdate.Year} - Stadium: { city.Stadium} ");
                                    cfile.WriteLine($"\t\tIn {city.Sdate.Year} - Stadium: { city.Stadium}");
                                    v_count++;
                                }
                                Console.WriteLine($"\n\t\t{outerGroup.Key.State}'s Super Bowl count is { v_count }.");
                                cfile.WriteLine($"\n\t\t{outerGroup.Key.State}'s Super Bowl count is { v_count }.");
                            }
                        }


                        cfile.Close();



                        //show list of players that have more than one mvp

                        using (StreamWriter dfile = File.AppendText(path))
                        {
                            dfile.WriteLine("\n\nPlayers who have more than one MVP:");
                            Console.WriteLine("\n\nPlayers who have more than one MVP:");

                            var MVPCount = from m in Team
                                           group m by m.MVP into MVPGroup
                                           where MVPGroup.Count() >= 2
                                           orderby MVPGroup.Key
                                           select MVPGroup;

                            foreach (var m in MVPCount)
                            {
                                Console.WriteLine($"{ m.Key } has {  m.Count() } MVPs.");
                                dfile.WriteLine($"{ m.Key } has {  m.Count() } MVPs.");
                            }

                            dfile.Close();
                        }


                        //coaches who lost the most superbowls

                        using (StreamWriter efile = File.AppendText(path))

                        {
                            efile.WriteLine("\n\nCoach who has lost the most Super Bowls:");
                            Console.WriteLine("\n\nCoach who has lost the most Super Bowls:");

                            var CoachLoss = from cl in Team
                                            .GroupBy(cl => cl.CoachLoser)
                                            select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in CoachLoss)
                            {
                                if (cl.Most == CoachLoss.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } lost { cl.Most } Super Bowls.");
                                    efile.WriteLine($"{ cl.Key } lost { cl.Most } Super Bowls.");
                                }
                                ;
                            }

                            efile.Close();
                        }


                        //coaches who won most superbowls

                        using (StreamWriter ffile = File.AppendText(path))

                        {
                            ffile.WriteLine("\n\nCoach won the most Super Bowls:");
                            Console.WriteLine("\n\nCoach won the most Super Bowls:");

                            var CoachWin = from cl in Team
                                           .GroupBy(cl => cl.CoachWinner)
                                           select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in CoachWin)
                            {
                                if (cl.Most == CoachWin.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } won { cl.Most } Super Bowls.");
                                    ffile.WriteLine($"{ cl.Key } won { cl.Most } Super Bowls.");
                                }
                                ;
                            }

                            ffile.Close();
                        }
                        //team won the most super bowls
                        using (StreamWriter gfile = File.AppendText(path))

                        {
                            gfile.WriteLine("\n\nTeam won the most Super Bowls:");
                            Console.WriteLine("\n\nTeam won the most Super Bowls:");

                            var TeamWin = from cl in Team
                                          .GroupBy(cl => cl.Winner)
                                          select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in TeamWin)
                            {
                                if (cl.Most == TeamWin.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } won { cl.Most } Super Bowls.");
                                    gfile.WriteLine($"{ cl.Key } won { cl.Most }Super Bowls.");
                                }
                                ;
                            }

                            gfile.Close();
                        }
                        //team lost the most super bowls
                        using (StreamWriter hfile = File.AppendText(path))

                        {
                            hfile.WriteLine("\n\nTeam lost the most Super Bowls:");
                            Console.WriteLine("\n\nTeam lost the most Super Bowls:");

                            var TeamLoser = from cl in Team
                                            .GroupBy(cl => cl.Loser)
                                            select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in TeamLoser)
                            {
                                if (cl.Most == TeamLoser.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } lost { cl.Most }Super Bowls.");
                                    hfile.WriteLine($"{ cl.Key } lost { cl.Most }Super Bowls.");
                                }
                                ;
                            }

                            hfile.Close();
                        }

                        //point difference

                        using (StreamWriter ifile = File.AppendText(path))

                        {
                            ifile.WriteLine("\n\nSuper Bowl with the highest Point Difference:");
                            Console.WriteLine("\n\nSuper Bowl with the highest Point Difference:");

                            var PointDiff = from cl in Team
                                            select new

                            {
                                cl.Sdate.Year,
                                cl.Winner,
                                Most = Math.Abs(cl.WinningPts - cl.LosingPts)
                            };

                            foreach (var cl in PointDiff)
                            {
                                if (cl.Most == PointDiff.Max(x => x.Most))
                                {
                                    Console.WriteLine($"The { cl.Year } Super Bowl, won by {cl.Winner}, had the biggest point difference of { cl.Most }.");
                                    ifile.WriteLine($"{ cl.Year } had the biggest point difference of { cl.Most }.");
                                }
                                ;
                            }

                            ifile.Close();
                            //average superbowl attendance

                            using (StreamWriter jfile = File.AppendText(path))

                            {
                                jfile.WriteLine("\n\nAverage attendance of Super Bowls:");
                                Console.WriteLine("\n\nAverage attendance of Super Bowls");

                                var AverageAtt = (from cl in Team
                                                  select cl.Attendance).Average();


                                Console.WriteLine($"The average Super Bowl attendance of all time is {Math.Round(AverageAtt)}.");
                                jfile.WriteLine($"The average Super Bowl attendance of all time is {Math.Round(AverageAtt)}.");

                                jfile.Close();
                            }

                            primer = Convert.ToString(Console.ReadLine().ToUpper());
                        }
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            //Declarations//
            const string PATH = @"C:\Users\foxsarh\Documents\Super_Bowl_Project.csv";

            FileStream   infile;
            FileStream   outFile;
            StreamReader read;
            StreamWriter writer;
            string       primer;

            string[] superBowlData;

            //*** add two more modules inside of main method ***///
            try
            {
                infile = new FileStream(PATH, FileMode.Open, FileAccess.Read);
                read   = new StreamReader(infile);
                primer = read.ReadLine(); // primer
                List <SuperBowl> superbowlList = new List <SuperBowl>();


                //Looping structure to read in all columns from CSV
                while (!read.EndOfStream)
                {
                    superBowlData = read.ReadLine().Split(',');
                    superbowlList.Add(new SuperBowl(superBowlData[0], superBowlData[1], Convert.ToInt32(superBowlData[2]), superBowlData[3],
                                                    superBowlData[4], superBowlData[5], Convert.ToInt32(superBowlData[6]), superBowlData[7], superBowlData[8], superBowlData[9],
                                                    Convert.ToInt32(superBowlData[10]), superBowlData[11], superBowlData[12], superBowlData[13], superBowlData[14]));
                }// end of while loop

                read.Dispose();
                infile.Dispose();

                //Introduction
                Console.WriteLine("-------------------------------------------");
                Console.WriteLine("    Welcome to The Super Bowl Database!    ");
                Console.WriteLine("-------------------------------------------");
                Console.WriteLine("You may choose the name of the file you would like your database to be saved in.");
                Console.WriteLine("It will be saved as a text file on your desktop\n");

                //Writing to a file --> don't need a using block since I will be writing to this file multiple times throughout the program and not just once
                string userName = Environment.UserName; //Grabs the username on the person's computer
                Console.Write("Please Enter the name of the text file: ");
                string userInput = Console.ReadLine();
                string filePath  = $@"C:\Users\{userName}\Desktop\{userInput}.txt";
                outFile = new FileStream(filePath, FileMode.Create, FileAccess.Write);
                writer  = new StreamWriter(outFile);

                //Conclusion
                Console.WriteLine("\n------------------------------------------------");
                Console.WriteLine("  Thank you for using the Super Bowl Database!  ");
                Console.WriteLine("------------------------------------------------");
                Console.WriteLine("Your file is stored at: " + filePath);

                //Print winners to file
                formatting("Winners", writer);
                writeDataToFile(superbowlList, "allWinners", writer);

                //Generate a list of top 5 most attendance superbowls
                var attendanceQuery = (from superbowl in superbowlList
                                       orderby superbowl.Attendance descending
                                       select superbowl).ToList <SuperBowl>().Take(5);

                //Print Top Five to file
                formatting("Top Five", writer);
                writeDataToFile(attendanceQuery.ToList(), "attendance", writer);
                //attendanceQuery.ToList<SuperBowl>().ForEach(x => Console.WriteLine($"1. Date = {x.Date}\n2. Winning Team = {x.Winner}\n3. Losing Team = {x.Loser}" +
                //$"\n4. City = {x.City}\n5. State = {x.State}\n6. Stadium = {x.Stadium}\n\n"));

                //Generate a list of the state that hosted the most super bowls
                int mostStates = superbowlList.GroupBy(x => x.State).OrderByDescending(x => x.Count()).First().Count();
                var stateQuery = (from SB in superbowlList
                                  group SB by SB.State into stateGroup
                                  where stateGroup.Count() == mostStates
                                  orderby stateGroup.Key descending
                                  select stateGroup).Take(1);

                formatting("State", writer);
                foreach (var x in stateQuery)
                {
                    writer.WriteLine($"{x.Key} hosted a total of {x.Count()} superbowls");

                    foreach (var superbowl in x)
                    {
                        writer.WriteLine($"1. The city = {superbowl.City}\n2. The Stadium = {superbowl.Stadium}\n\n");
                    }
                }

                /** Adapted from code originally by Leann Simonson **/
                //Generate a list of players who won MVP more than once
                var MVPCount = from x in superbowlList
                               group x by x.MVP into MVPGroup //create a group of the MVP data so it can be counted/quantified
                               where MVPGroup.Count() > 1
                               orderby MVPGroup.Key           // Order the list according to # of times a player was MVP
                               select MVPGroup;               // Return the ordered list of MVPs in List format
                /** end of citation **/

                formatting("MVP", writer);
                foreach (var x in MVPCount)
                {
                    writer.WriteLine($"\nPlayer {x.Key} won MVP {x.Count()} times");
                    writer.WriteLine("--------------------------------");

                    foreach (var superbowl in x)
                    {
                        writer.WriteLine($"Winning Team = {superbowl.Winner}\nLosing Team = {superbowl.Loser}\n");
                    }
                }
                writer.WriteLine(""); //formatting

                writer.WriteLine("----------------");
                writer.WriteLine(" Misc Fun Facts ");
                writer.WriteLine("----------------");

                //Determine which coach lost the most superbowls
                int mostCoachLosses  = superbowlList.GroupBy(x => x.CoachLoser).OrderByDescending(x => x.Count()).First().Count();
                var losingCoachQuery = (from SB in superbowlList
                                        group SB by SB.CoachLoser into losingCoachGroup
                                        where losingCoachGroup.Count() == mostCoachLosses
                                        //orderby losingCoachGroup.Key descending
                                        select losingCoachGroup.Key).ToArray();

                writer.WriteLine("\nThe Coaches Who Lost the Most Super Bowls:");
                for (var x = 0; x < losingCoachQuery.Length; x++)
                {
                    writer.WriteLine($"{losingCoachQuery[x]}");
                }

                //Determine which coach won the most superbowls
                int mostCoachWins     = superbowlList.GroupBy(x => x.CoachWinner).OrderByDescending(x => x.Count()).First().Count();
                var winningCoachQuery = (from SB in superbowlList
                                         group SB by SB.CoachWinner into winningCoachGroup
                                         where winningCoachGroup.Count() == mostCoachWins
                                         orderby winningCoachGroup.Key descending
                                         select winningCoachGroup).Take(1);

                foreach (var x in winningCoachQuery)
                {
                    writer.WriteLine($"\nThe coach who won the most super bowls = {x.Key}");
                }

                //Determine which team(s) won the most superbowls
                int mostWins    = superbowlList.GroupBy(x => x.Winner).OrderByDescending(x => x.Count()).First().Count();
                var winningTeam = (from SB in superbowlList
                                   group SB by SB.Winner into winnerGroup
                                   where winnerGroup.Count() == mostWins
                                   //orderby winnerGroup.Key descending
                                   select winnerGroup.Key).ToArray();

                writer.WriteLine("\nThe Teams Who Won the Most Super Bowls:");
                for (var x = 0; x < winningTeam.Length; x++)
                {
                    writer.WriteLine($"{winningTeam[x]}");
                }

                //Determine which team(s) lost the most superbowls
                int mostLosses = superbowlList.GroupBy(x => x.Loser).OrderByDescending(x => x.Count()).First().Count();
                var losingTeam = (from SB in superbowlList
                                  group SB by SB.Loser into loserGroup
                                  where loserGroup.Count() == mostLosses
                                  //orderby loserGroup.Key descending
                                  select loserGroup).Take(2);

                //Ouput which team lost the most supeprbowls
                writer.WriteLine("\nThe Teams Who Lost the Most Super Bowls:");
                foreach (var x in losingTeam)
                {
                    writer.WriteLine($"{x.Key}");
                }

                // DEBUGGING ----->> superbowlList.ForEach(x => Console.WriteLine(x.pointDifference()));

                //Determine which Superbowl had the greatest point difference
                var greatestPoint = (from SB in superbowlList
                                     group SB by SB.pointDifference() into pointsGroup
                                     orderby pointsGroup.Key descending
                                     select pointsGroup).Take(1);

                writer.WriteLine(""); //formatting
                foreach (var x in greatestPoint)
                {
                    foreach (var sb in x)
                    {
                        writer.WriteLine($"The Super Bowl with the greatest point difference:\n{sb.SuperBowlNumber} by {sb.pointDifference()} points");
                    }
                }

                //Determine the average attendance of all super bowls?
                double result = superbowlList.Select(x => x.Attendance).Average();
                writer.WriteLine(String.Format("\nThe average attendance of all super bowls is: {0:0,0}", result));

                writer.Close();
                outFile.Close();
            }// end of try

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            } // end of catch
        }     // End of Main
        static void Main(string[] args)
        {
            List <WinningTeam> Team         = new List <WinningTeam>();
            string             primingValue = "";
            string             textFile     = "";
            string             path         = "";

            Console.WriteLine("\nWhat is your name? (Enter X to exit.)");

            primingValue = Convert.ToString(Console.ReadLine());            //using primingValue for user name and also to exit out

            if (primingValue != "X" & primingValue != "x")
            {
                Console.WriteLine("\nWelcome " + primingValue + "! \n\nWhat is the path (folders & file name)\n" +
                                  "for the file from which we should read?\n\n" +
                                  "for example: C:\\Users\\simlea\\Desktop\\MyAssignments\\Project2\\Super_Bowl_Project.csv");

                textFile = @Console.ReadLine();

                Console.WriteLine(textFile);

                Console.WriteLine("\nWhat is the path (folders & file name)\n" +
                                  "for the file to which we should write?\n\n" +
                                  "for example: C:\\Users\\simlea\\Desktop\\MyAssignments\\Project2\\Super_Bowl_Report.txt");

                path = @Console.ReadLine();

                Console.WriteLine(path);

                //In case I wish to hard code...
                //textFile = @"C:\Users\simlea\Desktop\MyAssignments\Project2\Super_Bowl_Project.csv";
                //path = @"C:\Users\simlea\Desktop\MyAssignments\Project2\Super_Bowl_Report.txt";

                Console.Clear();
                Console.WriteLine("The Super Bowl Mega Report is being prepared and written to your location, as instructed.");

                try
                {
                    if (File.Exists(textFile))
                    {
                        using (StreamReader file = new StreamReader(textFile))

                        {
                            int    counter = 0;
                            string ln;
                            Regex  CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

                            while ((ln = file.ReadLine()) != null)

                            {
                                string[] col = CSVParser.Split(ln);

                                {
                                    //added this because I was going to skip the header, but for some reason I don't have to...figure out why it is skipping
                                    if (counter > 0)

                                    {
                                        WinningTeam team = new WinningTeam(col[0], col[1], col[2], col[3], col[4], col[5], col[6], col[7], col[8], col[9], col[10], col[11], col[12], col[13], col[14]);
                                        Team.Add(team);
                                        //Console.WriteLine(ln); don't need this for report, but can output the list called ln for testing.
                                    }
                                    counter++;
                                }
                            }
                            file.Close();
                            Console.WriteLine($"FYI: The file being read has {counter} lines.\nIt is outputted below, in addition to your file, for your convenience.\n\n");
                        }
                    }
                }
                catch (Exception e)
                //maybe later add specific exception such as catch FileNotFoundException
                {
                    Console.WriteLine("The process failed: {0}", e.ToString());
                }

                using (StreamWriter file = File.CreateText(path))

                {
                    Console.WriteLine("\n\nSuper Bowl Winners\n");
                    file.WriteLine("\n\nSuper Bowl Winners\n");

                    file.WriteLine("Team Name" + "\t\t" + "Year of Win" + "\t\t" + "Winning QB" + "\t\t" + "Winning Coach" + "\t\t" + "MVP" + "\t\t" + "Point Difference");
                    Console.WriteLine("Team Name" + "\t\t" + "Year of Win" + "\t\t" + "Winning QB" + "\t\t" + "Winning Coach" + "\t\t" + "MVP" + "\t\t" + "Point Difference");


                    foreach (WinningTeam item in Team)
                    {
                        file.WriteLine(item.Winner + "\t\t" + item.Sdate.Year + "\t\t" + item.QBWinner + "\t\t" + item.CoachWinner + "\t\t" + item.MVP + "\t\t" + (item.WinningPts - item.LosingPts));
                        Console.WriteLine(item.Winner + "\t\t" + item.Sdate.Year + "\t\t" + item.QBWinner + "\t\t" + item.CoachWinner + "\t\t" + item.MVP + "\t\t" + (item.WinningPts - item.LosingPts));
                    }

                    file.Close();


                    //Generate a list of the top five attended super bowls
                    using (StreamWriter bfile = File.AppendText(path))

                    {
                        bfile.WriteLine("Attendance" + "\t\t" + "Year of Win" + "\t\t" + "Winning Team" + "\t\t" + "Losing Team" + "\t\t" + "City" + "\t\t" + "State" + "\t\t" + "Stadium");
                        Console.WriteLine("Attendance" + "\t\t" + "Year of Win" + "\t\t" + "Winning Team" + "\t\t" + "Losing Team" + "\t\t" + "City" + "\t\t" + "State" + "\t\t" + "Stadium");

                        bfile.WriteLine("\n\nTop Five Attended Super Bowls\n");
                        Console.WriteLine("\n\nTop Five Attended Super Bowls\n");

                        //works...but not the point of exercise. Learning to use LINQ. So, replaced with other code. LeAnn
                        //int counter = 0;
                        //
                        //foreach (WinningTeam item in Team.OrderByDescending(x => x.Attendance))
                        //{
                        //	if (counter < 5)

                        //	{
                        //		bfile.WriteLine(item.Attendance + "\t" + item.Sdate.Year + "\t" + item.Winner + "\t" + item.Loser + "\t" + item.City + "\t" + item.State + "\t" + item.Stadium);
                        //		Console.WriteLine(item.Attendance + "\t" + item.Sdate.Year + "\t" + item.Winner + "\t" + item.Loser + "\t" + item.City + "\t" + item.State + "\t" + item.Stadium);

                        //	}
                        //	counter++;
                        //}

                        var qryTopFive = (from item in Team
                                          orderby item.Attendance descending
                                          select item).Take(5);

                        qryTopFive.ToList().ForEach(s => bfile.WriteLine(s.Attendance + "\t" + s.Sdate.Year + "\t" + s.Winner + "\t" + s.Loser + "\t" + s.City + "\t" + s.State + "\t" + s.Stadium));
                        qryTopFive.ToList().ForEach(s => Console.WriteLine(s.Attendance + "\t" + s.Sdate.Year + "\t" + s.Winner + "\t" + s.Loser + "\t" + s.City + "\t" + s.State + "\t" + s.Stadium));
                    }

                    file.Close();


                    //Generate a list of states that hosted the most super bowls
                    using (StreamWriter cfile = File.AppendText(path))

                    {
                        cfile.WriteLine("\n\nStates & Stats on SuperBowls Hosted\n");
                        Console.WriteLine("\n\nStates & Stats on SuperBowls Hosted\n");

                        //declare a variable, and allow the type to be determined at run time, so just "var" and name it "qryState"
                        //set it to the result of this query below
                        var qryState = from stateRecord in Team                         // start by selecting objects in the team list array
                                       group stateRecord by new                         // group these objects I'm now called "stateRecord" by state, I'm conceptualizing a "row"
                        {
                            stateRecord.State                                           // instructing the grouping to be teh State attribute
                        } into stateGroups                                              // but I want to group by another level, so I drop into another query with my state results
                        from cityGroups in                                              // and now we are going to focus on cities
                        (from city in stateGroups                                       // we are selecting objects in the stateGroups results
                         orderby city.City, city.Sdate.Year descending, city.Stadium    // and we are ordering them by city, then by year (descending) and then by stadium
                         group city by new { city.City })                               //and we want to group by city
                        orderby stateGroups.Key.State                                   //order the whole thing by state
                        group cityGroups by new { stateGroups.Key.State };              //group cities within states
                        //much of this felt backwards or upside down from straight up SQl coding.
                        //I thought through the parts and then researched how the parts fall together with what tweaks in syntax for LINQ
                        //this is akin to a cursor in database procedures


                        foreach (var outerGroup in qryState)                         //now we need to output the above query. We've used foreach in project 1. I'm created 2 levels to output with indents
                        {
                            Console.WriteLine($"{ outerGroup.Key.State }: ");
                            cfile.WriteLine($"{ outerGroup.Key.State }: ");
                            foreach (var detail in outerGroup)
                            {
                                Console.WriteLine($"\t{ detail.Key.City }");
                                cfile.WriteLine($"\t{ detail.Key.City }");

                                int v_count = 0;
                                foreach (var city in detail)

                                {
                                    Console.WriteLine($"\t\tIn {city.Sdate.Year} - Stadium: { city.Stadium} ");                                    //Using tabs for spacing
                                    cfile.WriteLine($"\t\tIn {city.Sdate.Year} - Stadium: { city.Stadium}");
                                    v_count++;
                                }
                                Console.WriteLine($"\n\t\t{outerGroup.Key.State}'s Super Bowl count is { v_count }.");                                 //displayed, but also taking a count to display count
                                cfile.WriteLine($"\n\t\t{outerGroup.Key.State}'s Super Bowl count is { v_count }.");
                            }
                        }


                        cfile.Close();



                        //Generate a list of players who won MVP more than twice

                        using (StreamWriter dfile = File.AppendText(path))
                        {
                            dfile.WriteLine("\n\nPlayers Who Won MVP More than Twice:");
                            Console.WriteLine("\n\nPlayers Who Won MVP More than Twice:");

                            var MVPCount = from m in Team
                                           group m by m.MVP into MVPGroup
                                           where MVPGroup.Count() > 2
                                           orderby MVPGroup.Key
                                           select MVPGroup;

                            foreach (var m in MVPCount)
                            {
                                Console.WriteLine($"{ m.Key } has {  m.Count() }.");
                                dfile.WriteLine($"{ m.Key } has {  m.Count() }.");
                            }

                            dfile.Close();
                        }


                        //Which coach lost the most super bowls?

                        using (StreamWriter efile = File.AppendText(path))

                        {
                            efile.WriteLine("\n\nCoach Who Lost the Most Super Bowls:");
                            Console.WriteLine("\n\nCoach Who Lost the Most Super Bowls:");

                            var CoachLoss = from cl in Team
                                            .GroupBy(cl => cl.CoachLoser)
                                            //orderby cl.Count() descending
                                            select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in CoachLoss)
                            {
                                if (cl.Most == CoachLoss.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } lost { cl.Most }.");
                                    efile.WriteLine($"{ cl.Key } lost { cl.Most }.");
                                }
                                ;
                            }

                            efile.Close();
                        }


                        //Which coach lost the most super bowls?

                        using (StreamWriter ffile = File.AppendText(path))

                        {
                            ffile.WriteLine("\n\nCoach Who Won the Most Super Bowls:");
                            Console.WriteLine("\n\nCoach Who Won the Most Super Bowls:");

                            var CoachWin = from cl in Team
                                           .GroupBy(cl => cl.CoachWinner)
                                           select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in CoachWin)
                            {
                                if (cl.Most == CoachWin.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } won { cl.Most }.");
                                    ffile.WriteLine($"{ cl.Key } won { cl.Most }.");
                                }
                                ;
                            }

                            ffile.Close();
                        }

                        using (StreamWriter gfile = File.AppendText(path))

                        {
                            gfile.WriteLine("\n\nTeam Who Won the Most Super Bowls:");
                            Console.WriteLine("\n\nTeam Who Won the Most Super Bowls:");

                            var TeamWin = from cl in Team
                                          .GroupBy(cl => cl.Winner)
                                          select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in TeamWin)
                            {
                                if (cl.Most == TeamWin.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } won { cl.Most }.");
                                    gfile.WriteLine($"{ cl.Key } won { cl.Most }.");
                                }
                                ;
                            }

                            gfile.Close();
                        }

                        using (StreamWriter hfile = File.AppendText(path))

                        {
                            hfile.WriteLine("\n\nTeam Who Lost the Most Super Bowls:");
                            Console.WriteLine("\n\nTeam Who Lost the Most Super Bowls:");

                            var TeamLoser = from cl in Team
                                            .GroupBy(cl => cl.Loser)
                                            select new

                            {
                                cl.Key,
                                Most = cl.Count()
                            };


                            foreach (var cl in TeamLoser)
                            {
                                if (cl.Most == TeamLoser.Max(x => x.Most))
                                {
                                    Console.WriteLine($"{ cl.Key } lost { cl.Most }.");
                                    hfile.WriteLine($"{ cl.Key } lost { cl.Most }.");
                                }
                                ;
                            }

                            hfile.Close();
                        }

                        using (StreamWriter ifile = File.AppendText(path))

                        {
                            ifile.WriteLine("\n\nSuper Bowl with the Greatest Point Difference:");
                            Console.WriteLine("\n\nSuper Bowl with the Greatest Point Difference:");

                            var PointDiff = from cl in Team
                                            select new

                            {
                                cl.Sdate.Year,
                                cl.Winner,
                                Most = Math.Abs(cl.WinningPts - cl.LosingPts)
                            };

                            foreach (var cl in PointDiff)
                            {
                                if (cl.Most == PointDiff.Max(x => x.Most))
                                {
                                    Console.WriteLine($"The { cl.Year } Super Bowl, won by {cl.Winner}, had the biggest point difference of { cl.Most }.");
                                    ifile.WriteLine($"{ cl.Year } had the biggest point difference of { cl.Most }.");
                                }
                                ;
                            }

                            ifile.Close();

                            using (StreamWriter jfile = File.AppendText(path))

                            {
                                jfile.WriteLine("\n\nAverage Attendance of All Super Bowls:");
                                Console.WriteLine("\n\nAverage Attendance of All Super Bowls:");

                                var AverageAtt = (from cl in Team
                                                  select cl.Attendance).Average();


                                Console.WriteLine($"The average Super Bowl attendance of all time is {Math.Round(AverageAtt)}.");
                                jfile.WriteLine($"The average Super Bowl attendance of all time is {Math.Round(AverageAtt)}.");

                                jfile.Close();
                            }

                            primingValue = Convert.ToString(Console.ReadLine().ToUpper());
                        }
                    }
                }
            }
        }