I know this seems very basic but my code reads in grades from a .dat file, it then counts how many of each grade there is and now i need to work out the percentage of each grade compared to the total number of grades. I hope this makes sense, any help will be greatly appreciated...

I hope this will do it:

private void CountGrades(/*parameter is here*/)
        {
            //put your ownn list of grades
            //you can pass them in the parameter from somewhere else!
            int[] array = new int[] { 3, 4, 5, 2, 2, 5, 4, 1, 2 }; 
            string strGrades = null;
            int all = array.Length;
            int total = 0;
            for (int i = 0; i < array.Length; i++)
            {
                total += array[i];
                strGrades += array[i].ToString() + Environment.NewLine;
            }
            int average = total / all;
            MessageBox.Show("Of the grades:\n" + strGrades + "the average is: " + total.ToString());
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.