Senin, 25 April 2016

C Program to find Student GPA and CGPA Concept of ENUM in C

,
C# Program to find Student GPA and CGPA

Program Statement:
Create a class of student which stores characteristcs of student like studentID, studentName, studentDOB, studentRollNo, studentEmail, studentGPA of last 5 semesters and other related information of the student. (You may set some properties Boolean and some readonly)
a. Calculate the CGPA of each student using function calculateCGPA(…).
b. Student with highest CGPA will be considerd CR of the class. There should be a function which will compare the CGPA of students and will declare a student having greater CGPA as CR.
c. Program should be able to take input of 5 students from user; definitely there will be a function which will take input from the user.
d. You have to use the Setter for setting the values of the data members of the class and and Getter function for getting the values of the data members of the class. (You can use property as alternative)
e. Default value for each student GPA should be 3.0. (You have to use an array for storing GPAs of 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 to 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 of copy constructor.
j. StudentID and StudentGPA of last 5 semesters must be constant or readonly.
k. Value of studentGPA of last 5 semesters must be selected from ENUM which may contain values {1.0, 2.0, 3.0, and 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**** ");
Console.Write(" Enter the Size of Student Class : ");
len = Convert.ToInt32(Console.ReadLine());
obj = new Student[len];
for (int j = 0; j < obj.Length; j++)
obj[j] = new Student();
do
{
Console.Clear();
Console.WriteLine("****A Program Calculate the Student Characteristcs**** ");
Console.WriteLine(" 1.Input Student Data");
Console.WriteLine(" 2.CGPA of Student");
Console.WriteLine(" 3.CR of Class");
Console.WriteLine(" 4.Copy Contructor");
Console.WriteLine(" 5.Operator Overload + ");
choice = Convert.ToChar(Console.ReadLine());
switch (choice)
{
case 1:
Console.Clear();
Console.Write(" Roll No. : " + obj[i].R);
Console.Write(" Enter Name : ");
obj[i].N = Convert.ToString(Console.ReadLine());
Console.Write(" Enter Father Name : ");
obj[i].F = Convert.ToString(Console.ReadLine());
Console.Write(" Enter Email : ");
obj[i].E = Convert.ToString(Console.ReadLine());
Console.Write(" Enter Date of Birth : ");
obj[i].D = Convert.ToDateTime(Console.ReadLine());
Console.Write(" Enter 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(" Enter Roll No. of Student : ");
R = Convert.ToInt32(Console.ReadLine());
for (int k = 0; k < len; k++)
{
loc = obj[k].Check(obj, R);
if (loc != -1)
{
obj[loc].CGPA();
break;
}
}
if (loc == -1)
Console.WriteLine(" Invalid 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(" Enter the No. for 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(" Enter 2 Object No. for Adding (i.e < 5/len) : ");
Console.Write(" Enter the Object No. for Adding : ");
R = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter the Object No. for Adding : ");
copy_r = Convert.ToInt32(Console.ReadLine());
obj[R] = obj[R-1] + obj[copy_r-1];
obj[R].Show();
count++;
}
break;
}
Console.Write(" If Run Again (Y/N) ? ");
choice = Convert.ToChar(Console.ReadLine());
if (choice != Y && choice != y)
{
Console.WriteLine(" See you Next Time");
Main_Fun();
break;
}
} while (true);
}


0 komentar to “C Program to find Student GPA and CGPA Concept of ENUM in C”

Posting Komentar

 

Make Money Online Now Free Copyright © 2016 -- Powered by Blogger