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

Exercise 3 - Counting Occurrences. (4 points) To start this exercise, download L

ID: 3879557 • Letter: E

Question

Exercise 3 - Counting Occurrences. (4 points) To start this exercise, download Lab01Ex03. zip archive and extract project LabolEx03 You have a program that analyzes a list of final averages. It then determines how many As, Bs, Cs, Ds, and Fs are in these grades. The averages are integer values on the scale of 0 to 100. They are stored in the array, which is given to you. (In real life, these values would probably come from a database somewhere) You are also given five defined variables: int iAs int iBs; int iCs; int iDs /B count // c count // D count There is also a partially completed method, which iterates over the array of grade averages and counts the letter grades based on the average values. The letter grade is determine according the usual grading scale:

Explanation / Answer

Program Screen Shot:-

Program Code:-

//Header Files
using System;
using System.Collections;
//Constants Class for grading
class Constants
{
    public const int A = 100-90;
    public const int B = 89-80;
    public const int C = 79-70;
    public const int D = 69-60;
    public const int F = 59-0;

}
//Grade distributor class for grade counting and printing
class GradeDistributor:Constants {
    int countF=0,countD=0,countC=0,countB=0,countA=0;
    //Method to find grade count
      public void DitributeGrade(ArrayList arr) {
      //Loop for arrayList elements comparison
         foreach (int i in arr) {
            if(i==A){
             countA++;  
            }
            else if(i==B){
             countB++;
            }
            else if(i==C){
             countC++;
             }
            else if(i==D){
             countD++;
            }
            else {
             countF++;
            }
         }
      }
      //method to print tabular column
       public void PrintDistribution(){
               int sum=countA+countB+countC+countD+countF;
               Console.WriteLine("GRADE Ditrubution :");
               Console.WriteLine("-------------------");
                Console.WriteLine("A     :      {0}",countA);
                Console.WriteLine("B     :      {0}",countB);
                Console.WriteLine("C     :      {0}",countC);
                Console.WriteLine("D     :      {0}",countD);
                Console.WriteLine("F     :      {0}",countF);
                Console.WriteLine("-------------------");
                Console.WriteLine(" Total:      {0}",sum);
            }
      }
    
    
//Main class
public class Test
{
   //main method
   public static void Main()
   {
       GradeDistributor gd = new GradeDistributor();//Reference for GradeDistributor class
               ArrayList al = new ArrayList();//Create arrayList for marks storing
               //Add values into arrayList
               al.Add(58);
               al.Add(88);
               al.Add(33);      
               al.Add(56);
               al.Add(12);
               al.Add(23);
               al.Add(9);
               //Call methods
               gd.DitributeGrade(al);
               gd.PrintDistribution();
  
/*Console.WriteLine("Press ESC to Exit");          
do {
    while (! Console.KeyAvailable) {
      
        //code
   }     
} while (Console.ReadKey(true).Key != ConsoleKey.Escape);*/
              
   }
}

---------------------------------------------------------------------------------------------------------------------

Output:-