rendered paste bodyusing System;
namespace StudentScores
{
class Program
{
static void Main ( string[] args )
{
int[,] StudentScores = new int[20, 4];
for ( int i = 0; i < 20; i++ )
{
for ( int j = 0; j < 4; j++ )
{
Console.Write( "Student {0}, exam {1} score: ", i + 1, j + 1 );
try
{
StudentScores[i, j] = Convert.ToInt32( Console.ReadLine() );
}
catch
{
Console.WriteLine( "Invalid score, please re-enter it." );
j -= 1;
}
}
}
Console.WriteLine( "\n\nStudent X: Exam 1; Exam 2; Exam 3; Exam 4; Exam Average\n" );
int Exam1Sum = 0;
int Exam2Sum = 0;
int Exam3Sum = 0;
int Exam4Sum = 0;
for ( int i = 0; i < 20; i++ )
{
string Output;
Output = "Student " + ( i + 1 ) + ": ";
int ExamScoreSum = 0;
for ( int j = 0; j < 4; j++ )
{
Output = Output + StudentScores[i, j] + "; ";
ExamScoreSum += StudentScores[i, j];
switch ( j )
{
case 0:
Exam1Sum += StudentScores[i, j];
break;
case 1:
Exam2Sum += StudentScores[i, j];
break;
case 2:
Exam3Sum += StudentScores[i, j];
break;
case 3:
Exam3Sum += StudentScores[i, j];
break;
default:
break;
}
}
Output = Output + ( ExamScoreSum / 4 );
Console.WriteLine( Output );
}
int Exam1Avg = Exam1Sum / 4;
int Exam2Avg = Exam2Sum / 4;
int Exam3Avg = Exam3Sum / 4;
int Exam4Avg = Exam4Sum / 4;
int TotalAvg = ( Exam1Sum + Exam2Sum + Exam3Sum + Exam4Sum ) / 4;
Console.WriteLine( "\nExam 1 Overall Average: {0}", Exam1Avg );
Console.WriteLine( "Exam 2 Overall Average: {0}", Exam2Avg );
Console.WriteLine( "Exam 3 Overall Average: {0}", Exam3Avg );
Console.WriteLine( "Exam 4 Overall Average: {0}", Exam4Avg );
Console.WriteLine( "All Exams Overall Average: {0}", TotalAvg );
Console.ReadKey( true );
}
}
}