Calculate Average Marks And Performance on the basis of marks in c#.
CODE:
Console.WriteLine("Enter No Of Students");
int nos = Convert.ToInt32(Console.ReadLine());
string[,] array1 = new string[nos, 8];
for (int i = 0; i < nos; i++)
{
Console.WriteLine("Enter name of student:{0}",i+1);
array1[i, 0] = Console.ReadLine();
Console.WriteLine("Enter Marks Of Physics for student:{0}",i+1);
array1[i, 1] = Console.ReadLine();
Console.WriteLine("Enter Marks Of Chemistry for student:{0}", i + 1);
array1[i, 2] = Console.ReadLine();
Console.WriteLine("Enter Marks Of Maths for student:{0}", i + 1);
array1[i, 3] = Console.ReadLine();
}
for (int i = 0; i < nos; i++)
{
int physics = Convert.ToInt32(array1[i,1]);
int chemistry = Convert.ToInt32(array1[i, 2]);
int math = Convert.ToInt32(array1[i, 3]);
double totalmarks = physics + chemistry + math;
double percentage = totalmarks * 100 / 300;
array1[i, 4] = Convert.ToString(totalmarks);
array1[i, 5] = Convert.ToString(percentage);
double avergemarks = totalmarks / 3;
array1[i, 6] = avergemarks.ToString();
string performance;
if (avergemarks>80)
{
performance = "exellent";
}
else if (avergemarks>70 && avergemarks<80)
{
performance = "Very good";
}
else if (avergemarks>60 && avergemarks<70)
{
performance = "Good";
}
else
{
performance = "Need Improvement";
}
array1[i, 7] = performance;
}
Console.WriteLine("\nStudent Data with Total Marks and Percentage:");
Console.WriteLine("---------------------------------------------------------------------------------------------");
Console.WriteLine("| Name | Physics | Chemistry | Mathematics | Total Marks |Percentage|Average|Performance");
Console.WriteLine("-----------------------------------------------------------------------------------------------");
for (int i = 0; i < nos; i++)
{
for (int j = 0; j <8 ; j++)
{
Console.Write("| {0} ",array1[i,j]);
}
Console.WriteLine();
}
}
}
}
Comments
Post a Comment