INSTRUCTIONS
-Use C#.Net 2010
-Write ONE program for that question.
-Use suitable labels for your output
1. Given the name and marks of n=10 students for the course C# Programming.
(a) Calculate their grades (0-49 = F, 50-64 = C, 65-79 = B, 80-100 = A).
(b) Calculate the average, minimum, maximum marks.
Write a program to generate a report that resembles the below
EXAMINATION REPORT
C# PROGRAMMING
No. Student Name Mark Grade
1 AAA 88 A
2 BBB 45 B
3 CCC 60 C
....
Average mark =...
Minimum mark =...
Maximum mark =...
Loading

Hemant SrivastavaPosted Apr 7, 2015, 4:07 PM
Try this:
namespace ConsoleApplication1
{
class Student
{
public string sName { get; set; }
public int iMarks { get; set; }
public string sGrade { get; set; }
public Student(string name, int marks)
{
sName = name;
iMarks = marks;
}
}
class Program
{
public static void Main(string[] args)
{
try
{
int N = 0;
decimal Avg = 0;
decimal Min = 9999;
decimal Max = 0;
int Total = 0;
Student[] studentList = null;
Console.WriteLine("For how many student's record you want to enter: ");
string n = Console.ReadLine();
if (Int32.TryParse(n, out N))
{
studentList = new Student[N];
for (int i = 0; i < N; i++)
{
Console.WriteLine("For student- " + (i + 1) + ", Enter Name: ");
string name = Console.ReadLine();
Console.WriteLine("For student " + (i + 1) + "Enter Marks: ");
string sMrks = Console.ReadLine();
int marks = 0;
Int32.TryParse(sMrks, out marks);
studentList[i] = new Student(name, marks);
//Deciding grades (Criteria: 0-49 = F, 50-64 = C, 65-79 = B, 80-100 = A)
if (studentList[i].iMarks <= 49)
{
studentList[i].sGrade = "F";
}
else if (studentList[i].iMarks <= 64)
{
studentList[i].sGrade = "C";
}
else if (studentList[i].iMarks <= 79)
{
studentList[i].sGrade = "B";
}
else if (studentList[i].iMarks <= 100)
{
studentList[i].sGrade = "A";
}
// Calculating Total
Total = Total + studentList[i].iMarks;
// Calculating Minimum
if (studentList[i].iMarks < Min)
{
Min = studentList[i].iMarks;
}
// Calculating Maximum
if (studentList[i].iMarks > Max)
{
Max = studentList[i].iMarks;
}
}
}
if (N > 0)
{
Console.WriteLine("\n\nName\t Marks\t Grade");
for (int i = 0; i < N; i++)
{
Console.WriteLine(studentList[i].sName + "\t" + studentList[i].iMarks + "\t" + studentList[i].sGrade);
}
Console.WriteLine();
Avg = Total / N;
Console.WriteLine("Average = " + Avg);
Console.WriteLine("Minimum = " + Min);
Console.WriteLine("Maximum = " + Max);
}
Console.ReadLine();
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
Console.ReadLine();
}
}
}
}
Amex JohnnyPosted Apr 7, 2015, 8:07 AM
Deepak SainiPosted Apr 7, 2015, 6:37 AM
if u are using sql server and you calculate max,min,avg aggergate function and put into dynamic table and display in page.
you put these values in a array and find min ,max and avg in array.