107 325
Assignments Done
98.9%
Successfully Done
In March 2023

# Answer to Question #43688 in C# for MUTHURAMAN.N

Question #43688
simple c#program to get student details including name roll no, and also to calculate the average total,display in table and also give grades using call by value method
1
2014-06-26T10:27:01-0400
usingSystem;

classProgram
{

class Subject
{
private intmark;
private stringname;

publicSubject(string name, intmark)
{
this.name= name;
this.mark= mark;
}

public intGetMark()
{
returnmark;
}

public voidPrintSubject()
{
Console.WriteLine("|{0, -10} | {1, 10} |", name,mark);
}
}

// Student details
static stringname;
static int no;
static Subject[]subjects = newSubject[5];
static intnumOfSub = 0;

//By value method
{
subjects[numOfSub] = newSubject(name,mark);
numOfSub++;
}

public static floatAverage()
{
intsum = 0;
for (int i = 0; i <numOfSub; i++)
{
sum =sum + subjects[i].GetMark();
}

return (float)sum / numOfSub;
}

public static voidDisplay()
{
Console.WriteLine("---------------------------");
Console.WriteLine("|Student {0, -7} no. {1, 3} |",name, no);
for (int i = 0; i <numOfSub; i++)
{
Console.WriteLine("---------------------------");
subjects[i].PrintSubject();
}
Console.WriteLine("---------------------------");
Console.WriteLine("|Average: {0, 6} |",Average());
Console.WriteLine("---------------------------");

}

public static voidMain()
{

Console.Write("Enterroll no: ");

stringsubjectName;
intsubjectMark;

Console.Write("Entersubject name: ");
Console.Write("Entersubject mark: ");

Console.Write("Entersubject name: ");
Console.Write("Entersubject mark: ");

Display();

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!