using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Project2 { class Program { static void Main(string[] args) { int[] ageForPeople = new int[10000]; int[] DistrictForCensus = new int[10000]; int[] agesForCensusGroups = new int[5]; int[] maxDistrictAmount = new int[22]; int placeValueHolder = 0; foreach (string line in File.ReadAllLines("census.txt")) { string[] fields = line.Split(','); ageForPeople[placeValueHolder] = int.Parse(fields[0]); DistrictForCensus[placeValueHolder] = int.Parse(fields[3]); if (ageForPeople[placeValueHolder] > 0 && ageForPeople[placeValueHolder] <= 18) { agesForCensusGroups[0]++; } if (ageForPeople[placeValueHolder] > 18 && ageForPeople[placeValueHolder] <= 30) { agesForCensusGroups[1]++; } if (ageForPeople[placeValueHolder] > 30 && ageForPeople[placeValueHolder] <= 45) { agesForCensusGroups[2]++; } if (ageForPeople[placeValueHolder] > 45 && ageForPeople[placeValueHolder] <= 64) { agesForCensusGroups[3]++; } if (ageForPeople[placeValueHolder] >= 65) { agesForCensusGroups[4]++; } //District Count info if (DistrictForCensus[placeValueHolder] == 1) { maxDistrictAmount[0]++; } if (DistrictForCensus[placeValueHolder] == 2) { maxDistrictAmount[1]++; } if (DistrictForCensus[placeValueHolder] == 3) { maxDistrictAmount[2]++; } if (DistrictForCensus[placeValueHolder] == 4) { maxDistrictAmount[3]++; } if (DistrictForCensus[placeValueHolder] == 5) { maxDistrictAmount[4]++; } if (DistrictForCensus[placeValueHolder] == 6) { maxDistrictAmount[5]++; } if (DistrictForCensus[placeValueHolder] == 7) { maxDistrictAmount[6]++; } if (DistrictForCensus[placeValueHolder] == 8) { maxDistrictAmount[7]++; } if (DistrictForCensus[placeValueHolder] == 9) { maxDistrictAmount[8]++; } if (DistrictForCensus[placeValueHolder] == 10) { maxDistrictAmount[9]++; } if (DistrictForCensus[placeValueHolder] == 11) { maxDistrictAmount[10]++; } if (DistrictForCensus[placeValueHolder] == 12) { maxDistrictAmount[11]++; } if (DistrictForCensus[placeValueHolder] == 13) { maxDistrictAmount[12]++; } if (DistrictForCensus[placeValueHolder] == 14) { maxDistrictAmount[13]++; } if (DistrictForCensus[placeValueHolder] == 15) { maxDistrictAmount[14]++; } if (DistrictForCensus[placeValueHolder] == 16) { maxDistrictAmount[15]++; } if (DistrictForCensus[placeValueHolder] == 17) { maxDistrictAmount[16]++; } if (DistrictForCensus[placeValueHolder] == 18) { maxDistrictAmount[17]++; } if (DistrictForCensus[placeValueHolder] == 19) { maxDistrictAmount[18]++; } if (DistrictForCensus[placeValueHolder] == 20) { maxDistrictAmount[19]++; } if (DistrictForCensus[placeValueHolder] == 21) { maxDistrictAmount[20]++; } if (DistrictForCensus[placeValueHolder] == 22) { maxDistrictAmount[21]++; } placeValueHolder++; }//End For Console.WriteLine("This provides a list of residents in 5 different age groups,"); Console.WriteLine("Also it provides a list of residents in each of the district 1-22"); Console.WriteLine("-------Ages of people, in all districts-------"); Console.WriteLine("Age Group 18 & under = {0}", agesForCensusGroups[0]); Console.WriteLine("Age Group 18-30 = {0}", agesForCensusGroups[1]); Console.WriteLine("Age Group 31-45 = {0}", agesForCensusGroups[2]); Console.WriteLine("Age Group 46-64 = {0}", agesForCensusGroups[3]); Console.WriteLine("Age Group 65 & over = {0}", agesForCensusGroups[4]); Console.WriteLine("-------Amount of people in each district-------"); for (int z = 1; z <= 22; z++) { Console.WriteLine("District {0} = {1}", z, maxDistrictAmount[z - 1]); } } } } This is what i have so far.. i do not know how to further condese the if statements, ie: the districtForCensus displays sequentally all districts. is there a way to make it go one after another, with out 22 if statements