All pastes #430244 Raw Edit

Kitchen

public text v1 · immutable
·published 2007-04-08 20:58 UTC
rendered paste body
using System;

namespace StudentScores
{
    class Program
    {
        static void Main ( string[] args )
        {
            int[,] StudentScores = new int[20, 4]; // Create the array that will store the student's scores

            for ( int i = 0; i < 20; i++ ) // Loop through each of the students
            {
                for ( int j = 0; j < 4; j++ ) // Loop through each of their exams
                {
                    Console.Write( "Student {0}, exam {1} score: ", i + 1, j + 1 ); // Increase i/j + 1 to fix the Student 0, Exam 0 bug

                    try // try...catch... to make sure they enter a number, and not a string or space
                    {
                        StudentScores[i, j] = Convert.ToInt32( Console.ReadLine() ); // Set the array for the current student's exam
                    }
                    catch
                    {
                        Console.WriteLine( "Invalid score, please re-enter it." ); // Let them know they entered an invalid score
                        j -= 1; // To counter the j++ at the end of the for.. loop
                    }
                }
            }

            // Here you need to loop through the StudentScores array and calculate and output whatever you
            // need to. Good luck :D

        }
    }
}