Exemple #1
0
 /// <summary>
 /// Returns the number of students assignments
 /// </summary>
 /// <returns>int length</returns>
 public int GetStudentAssignmentsCount()
 {
     try
     {
         return(StudentScores.GetLength(1));
     }
     catch (Exception ex)
     {
         //This is the top level method so we want to handle the exception
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                             MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
Exemple #2
0
        /// <summary>
        /// Generates a string to display all the student's scores
        /// </summary>
        /// <param name="preDisplay">Header string</param>
        /// <returns>String display</returns>
        public String GenerateDisplay(String preDisplay)
        {
            String display = preDisplay;

            try
            {
                for (int i = 0; i < StudentNames.Length; ++i)
                {
                    double sum = 0;
                    display += Environment.NewLine;

                    display += StudentNames[i] + "\t\t";

                    for (int j = 0; j < StudentScores.GetLength(1); ++j)
                    {
                        display += StudentScores[i, j] + "\t";
                        sum     += StudentScores[i, j];
                    }

                    double average = (sum / StudentScores.GetLength(1));
                    display += average + "\t";

                    String letterGrade;
                    if (average >= 93)
                    {
                        letterGrade = "A";
                    }
                    else if (average >= 90)
                    {
                        letterGrade = "A-";
                    }
                    else if (average >= 87)
                    {
                        letterGrade = "B+";
                    }
                    else if (average >= 83)
                    {
                        letterGrade = "B";
                    }
                    else if (average >= 80)
                    {
                        letterGrade = "B-";
                    }
                    else if (average >= 77)
                    {
                        letterGrade = "C=";
                    }
                    else if (average >= 73)
                    {
                        letterGrade = "C";
                    }
                    else if (average >= 70)
                    {
                        letterGrade = "C-";
                    }
                    else if (average >= 67)
                    {
                        letterGrade = "D+";
                    }
                    else if (average >= 63)
                    {
                        letterGrade = "D";
                    }
                    else if (average >= 60)
                    {
                        letterGrade = "D-";
                    }
                    else
                    {
                        letterGrade = "F";
                    }
                    display += letterGrade;
                }
            }
            catch (Exception ex)
            {
                //This is the top level method so we want to handle the exception
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }

            return(display);
        }