Search

#include<iostream.h>
#include<conio.h>
void cgpa_input();
void main()
{
 clrscr();
 cgpa_input();
 getch();
}
void cgpa_input()
{
 int m[15],i,n,mn;
 float g[15],total=0,gtotal=0,cgpa;
 char ma[15],sc[10][15],sem[15],name[15],year[15],dept[15];
 cout<<"\n Enter the student name:";
 cin>>name;
 cout<<"\n Enter the department:";
 cin>>dept;
 cout<<"\n Enter the Year of student:";
 cin>>year;
 cout<<"\n Enter the semester of the student:";
 cin>>sem;
 cout<<"\n Enter the No. of Subjects:";
 cin>>n;
 cout<<"\n Enter the grades in (S-E) F-arrear";
 for(i=0;i<n;i++)
 {
  cout<<"\n Enter the subject code,grades in(S-E),grade points:";
  cin>>sc[i]>>ma[i]>>g[i];
 }
 for(i=0;i<n;i++)
 {
  switch(ma[i])
  {
   case 'S':
   case 's':
  m[i]=10;
  break;
   case 'A':
   case 'a':
  m[i]=9;
  break;
   case 'B':
   case 'b':
  m[i]=8;
  break;
   case 'C':
   case 'c':
  m[i]=7;
  break;
   case 'D':
   case 'd':
  m[i]=6;
  break;
   case 'E':
   case 'e':
  m[i]=5;
  break;
   case 'F':
   case 'f':
  mn=0;
  break;
  }
 }
 if(mn==0)
 {
  clrscr();
  cout<<"\n\tNAME:"<<name<<"\t\tDEPARTMENT:"<<dept<<endl;
  cout<<"\n\tYEAR:"<<year<<"\t\tSEMESTER:"<<sem<<endl;
  cout<<"\n Subject code          Grade";
  for(i=0;i<n;i++)
  {
   cout<<"\n\t"<<sc[i]<<"\t\t"<<ma[i];
  }
  cout<<"\n\nCGPA=ARREAR";
 }
 else
 {
  clrscr();
  cout<<"\n\tNAME:"<<name<<"\t\tDEPARTMENT:"<<dept<<endl;
  cout<<"\n\tYEAR:"<<year<<"\t\tSEMESTER:"<<sem<<endl;
  cout<<"\n Subject code          Grade";
  for(i=0;i<n;i++)
  {
   cout<<"\n\t"<<sc[i]<<"\t\t"<<ma[i];
  }
   for(i=0;i<n;i++)
  {
   total=total+(m[i]*g[i]);
  }
  for(i=0;i<n;i++)
  {
   gtotal=gtotal+g[i];
  }
  cgpa=total/gtotal;
  cout<<"\n\nCGPA="<<cgpa;
 }
}

Output:

Enter the student name:Rajiv Ranjan V
Enter the department:Mechanical
Enter the year of student:4
Enter the semester of the student:7
Enter the No. of  Subjects:8
Enter the grades in (S-E) F-arrear
Enter the subject code:701
Enter the grades in (S-E):S
Enter the grade point:3.5
Enter the subject code:702
Enter the grades in (S-E):A
Enter the grade point:3.5
Enter the subject code:703
Enter the grades in (S-E):A
Enter the grade point:3
Enter the subject code:704
Enter the grades in (S-E):B
Enter the grade point:3
Enter the subject code:705
Enter the grades in (S-E):A
Enter the grade point:3
Enter the subject code:706
Enter the grades in (S-E):A
Enter the grade point:3.5
Enter the subject code:711
Enter the grades in (S-E):S
Enter the grade point:1.5
Enter the subject code:712
Enter the grades in (S-E):S
Enter the grade point:1.5
                    NAME:Rajiv Ranjan V                      DEPARTMENT:Mechanical
                    YEAR:4                                              SEMESTER:7
Subject code                                 Grade
       701                                            S
       702                                            A
       703                                            A
       704                                            B
       705                                            A
       706                                            A
       711                                            S
       712                                            S
CGPA=9.1555555556
Press enter key to exit....





                                                               
Source Code:
def cgpa_display():
total1=0
gtotal=0
grades={"s":"10","S":"10","a":"9","A":"9","b":"8", "B":"8","c":"7", "C":"7","d":"6","D":"6","e":"5","E":"5","f":"4","F":"4"}
name=raw_input("\n Enter the student name:")
dept=raw_input("\n Enter the department:")
year=raw_input("\n Enter the Year of student:")
sem=raw_input("\n Enter the semester of the student:")
n=int(raw_input("\n Enter the No. of Subjects:"))
print"\n Enter the grades in (S-E) F-arrear"
marks=[]
for entry in range(n):
sc=raw_input("\n Enter the subject code:")
ma=raw_input("\n Enter the grades in (S-E):")
g=float(raw_input("\n Enter the grade points:"))
if ma in grades:
m=float(grades[ma])
ma=ma.upper()
entry=(sc,g,m,ma)
marks.append(entry)
if ma=="F":
mn="0"
else:
mn="1"
  if mn=="0":
  print"\n\tNAME:",name,"\t\tDEPARTMENT:",dept
  print"\n\tYEAR:",year,"\t\tSEMESTER:",sem
  print"\n Subject code          Grade"
  for entry in marks:
  sc,g,m,ma=entry
  print"\n\t",sc,"\t\t",ma
            print"\n\nCGPA=ARREAR"
       else:
           print"\n\tNAME:",name,"\t\tDEPARTMENT:",dept
            print"\n\tYEAR:",year,"\t\tSEMESTER:",sem
           print"\n Subject code          Grade"
           for entry in marks:
  sc,g,m,ma=entry
  print"\n\t",sc,"\t\t",ma
  total1=total1+m*g
                gtotal=gtotal+g
  cgpa=total1/gtotal
  print"\n\nCGPA=",cgpa
cgpa_display()
raw_input("\n Press enter key to exit....")

Output:

Enter the student name:Rajiv Ranjan V
Enter the department:Mechanical
Enter the year of student:4
Enter the semester of the student:7
Enter the No. of  Subjects:8
Enter the grades in (S-E) F-arrear
Enter the subject code:701
Enter the grades in (S-E):S
Enter the grade point:3.5
Enter the subject code:702
Enter the grades in (S-E):A
Enter the grade point:3.5
Enter the subject code:703
Enter the grades in (S-E):A
Enter the grade point:3
Enter the subject code:704
Enter the grades in (S-E):B
Enter the grade point:3
Enter the subject code:705
Enter the grades in (S-E):A
Enter the grade point:3
Enter the subject code:706
Enter the grades in (S-E):A
Enter the grade point:3.5
Enter the subject code:711
Enter the grades in (S-E):S
Enter the grade point:1.5
Enter the subject code:712
Enter the grades in (S-E):S
Enter the grade point:1.5
                    NAME:Rajiv Ranjan V                                         DEPARTMENT:Mechanical
                    YEAR:4                                              SEMESTER:7
Subject code                                 Grade
       701                                            S
       702                                            A
       703                                            A
       704                                            B
       705                                            A
       706                                            A
       711                                            S
       712                                            S
CGPA=9.1555555556
Press enter key to exit....