i want to create a program with the grades in a school. we have to find the average of the grades depending on how many courses the student has chosen.
also, we have to find how many courses each studend has passed.
the user has to give the number of the students in a class
for each student we have to give the number of the courses he has taken
for each course, we have to give the grades from a test and from the final exams
my teacher gave me the main class. i have solved a part from the problem but i don't think that it's correct. Need your help
using System;
namespace Lab6Exercise1
{
class MainClass
{
public static void Main(string[] args)
{
int N;
Console.WriteLine ("Number Of Students");
N=Int32.Parse(Console.ReadLine());
Students[] M=new Students[N];
for (int i = 0; i < N; i++)
{
Console.WriteLine("Number of courses for the {0}st student:", i + 1);
int n = Int32.Parse(Console.ReadLine());
M[i] = new Students(n);
Console.WriteLine("Name:");
M[i].SetName(Console.ReadLine());
Console.WriteLine("Code");
M[i].SetCode(Console.ReadLine());
M[i].Grades();
double average;
M[i].AVERAGE(out average);
Console.WriteLine("{0},{1},AVERAGE:{2:.00},Passed_Courses:{3}", M[i].GetCode(), M[i].GetName(), average, M[i].GetNumberPass());
}
}
}
}
using System;
namespace Project1lab6
{
public class Grade
{
//the variables given from the teacher
double test;
double final_exams;
bool pass;
public void Grades (int n)
{
for (int i = 0; i < n; i++)
{
do
{
Console.WriteLine("give grade of test");
test = Double.Parse(Console.ReadLine());
} while (test < 0 || test > 10);
do
{
Console.WriteLine("give grade from final exams");
final_exams = Double.Parse(Console.ReadLine());
} while (final_exams < 0 || final_exams > 10);
}
}
public double AVERAGE(out double average)
{
average = test * 0.4 + final_exams * 0.6;
if (average >= 5.0)
pass = true;
return average;
}
}
}
using System;
namespace Project1lab6
{
public class Students
{
//the variables given from the teacher
string name;
string Code;
Grades[] grades;
int NumberPass = 0;
//set&get
public void SetName(string Name)
{
this.name = Name;
}
public string GetName()
{
return name;
}
public void SetCode(string Code)
{
this.Code = Code;
}
public string GetCode()
{
return Code;
}
public void SetNumberPass(bool pass)
{
if (pass == true)
NumberPass++;
}
public int GetNumberPass()
{
return NumberPass;
}
}
}