C# Program toward find Student GPA furthermore CGPA
Program Statement:
Create a class regarding student which stores characteristcs regarding student like studentID, studentName, studentDOB, studentRollNo, studentEmail, studentGPA regarding last 5 semesters furthermore other related information regarding the student. (You may set some properties Boolean furthermore some readonly)
a. Calculate the CGPA regarding each student using function calculateCGPA(…).
b. Student with highest CGPA will be considerd CR regarding the class. There should be a function which will compare the CGPA regarding students furthermore will declare a student having greater CGPA as CR.
c. Program should be able toward take input regarding 5 students from user; definitely there will be a function which will take input from the user.
d. You have toward use the Setter beneficial to setting the values regarding the data members regarding the class furthermore and Getter function beneficial to getting the values regarding the data members regarding the class. (You can use property as alternative)
e. Default value beneficial to each student GPA should be 3.0. (You have toward use an array beneficial to storing GPAs regarding last 5 semesters. You may simply initialize the array with 3.0 in constructor).
f. All data members should be private.
g. Member functions can be public.
h. Program must be able toward add two objects i.e. if we add two students then all their corresponding data members will be added one by one. (Operator Overloading).
i. Program must contain explicitly definition regarding copy constructor.
j. StudentID furthermore StudentGPA regarding last 5 semesters must be constant or readonly.
k. Value regarding studentGPA regarding last 5 semesters must be selected from ENUM which may contain values {1.0, 2.0, 3.0, furthermore 4.0}.
Solution:
public void Question_45()
{
int len = 0, i = 0, count = 0 , R , copy_r;
Student[] obj;
Console.Clear();
Console.WriteLine("****A Program Calculate the Student Characteristcs****\n");
Console.Write("\nEnter the Size regarding Student Class : ");
len = Convert.ToInt32(Console.ReadLine());
obj = new Student[len];
beneficial to (int j = 0; j < obj.Length; j++)
obj[j] = new Student();
do
{
Console.Clear();
Console.WriteLine("****A Program Calculate the Student Characteristcs****\n");
Console.WriteLine("\n\t\t1.Input Student Data");
Console.WriteLine("\t\t2.CGPA regarding Student");
Console.WriteLine("\t\t3.CR regarding Class");
Console.WriteLine("\t\t4.Copy Contructor");
Console.WriteLine("\t\t5.Operator Overload + ");
choice = Convert.ToChar(Console.ReadLine());
switch (choice)
{
case '1':
Console.Clear();
Console.Write("\nRoll No. : " + obj[i].R);
Console.Write("\n\nEnter Name : ");
obj[i].N = Convert.ToString(Console.ReadLine());
Console.Write("\nEnter Father Name : ");
obj[i].F = Convert.ToString(Console.ReadLine());
Console.Write("\nEnter Email : ");
obj[i].E = Convert.ToString(Console.ReadLine());
Console.Write("\nEnter Date regarding Birth : ");
obj[i].D = Convert.ToDateTime(Console.ReadLine());
Console.Write("\nEnter Smester : ");
obj[i].Sm = Convert.ToInt32(Console.ReadLine());
obj[i].Set_GPA();
i++;
count++;
break;
case '2':
if (count != 0)
{
int loc = -1;
Console.Clear();
Console.Write("\nEnter Roll No. regarding Student : ");
R = Convert.ToInt32(Console.ReadLine());
beneficial to (int k = 0; k < len; k++)
{
loc = obj[k].Check(obj, R);
if (loc != -1)
{
obj[loc].CGPA();
break;
}
}
if (loc == -1)
Console.WriteLine("\nInvalid Roll No.");
count++;
}
break;
case '3':
if (count != 0)
{
Console.Clear();
obj[0].CR(obj);
count++;
}
break;
case '4':
if (count != 0)
{
Console.Clear();
Console.Write("\nEnter the No. beneficial to Copy (i.e < 5/len) : ");
copy_r = Convert.ToInt32(Console.ReadLine());
Student copy = new Student(obj[copy_r-1]);
copy.Show();
count++;
}
break;
case '5':
if (count != 0)
{
Console.Clear();
Console.Write("\nEnter 2 Object No. beneficial to Adding (i.e < 5/len) : ");
Console.Write("\nEnter the Object No. beneficial to Adding : ");
R = Convert.ToInt32(Console.ReadLine());
Console.Write("\nEnter the Object No. beneficial to Adding : ");
copy_r = Convert.ToInt32(Console.ReadLine());
obj[R] = obj[R-1] + obj[copy_r-1];
obj[R].Show();
count++;
}
break;
}
Console.Write("\nIf Run Again (Y/N) ? ");
choice = Convert.ToChar(Console.ReadLine());
if (choice != 'Y' && choice != 'y')
{
Console.WriteLine("\nSee you Next Time");
Main_Fun();
break;
}
} while (true);
}