Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Tuesday, January 4, 2011

Design a STUDENT class to store roll, name, course, admission date and marks in 5 subjects. Provide methods corresponding to admission date and receiving marks, preparing marks sheet. Support must be there to show the number of students who have taken admission.

Source Code :

#include<iostream.h>
#include<iomanip.h>
using namespace std;
class student {
      char name[20];
      char course[20];
      char ad_date[10];
      int marks[5];
      public:
      int roll;
      void get_dt() {
            cout<<endl<<"Enter Name : ";
            cin>>name;
            cout<<endl<<"Enter Course : ";
            cin>>course;
            cout<<endl<<"Enter Admission Date : ";
            cin>>ad_date;
      }
      void recv_marks() {
            cout<<endl<<"Enter Marks for English : ";
            cin>>marks[0];
            cout<<endl<<"Enter Marks for Bengali : ";
            cin>>marks[1];
            cout<<endl<<"Enter Marks for Maths : ";
            cin>>marks[2];
            cout<<endl<<"Enter Marks for Science : ";
            cin>>marks[3];
            cout<<endl<<"Enter Marks for Computer : ";
            cin>>marks[4];
      }
      void prep() {
            int total = marks[0]+marks[1]+marks[2]+marks[3]+marks[4];
            cout<<endl<<"Roll No \t: "<<roll;
            cout<<endl<<"Name of Student : "<<name;
            cout<<endl<<"Course \t\t: "<<course;
            cout<<endl<<"Admission Date \t: "<<ad_date;
            cout<<endl<<"================================";
            cout<<endl<<setw(8)<<"Subject"<<setw(15)<<"Marks";
            cout<<endl<<setw(8)<<"English"<<setw(15)<<marks[0];
            cout<<endl<<setw(8)<<"Bengali"<<setw(15)<<marks[1];
            cout<<endl<<setw(8)<<"Maths"<<setw(15)<<marks[2];
            cout<<endl<<setw(8)<<"Science"<<setw(15)<<marks[3];
            cout<<endl<<setw(8)<<"Computer"<<setw(15)<<marks[4];
            cout<<endl<<"=================================";
            cout<<endl<<setw(8)<<"Total"<<setw(15)<<total;
            cout<<endl<<"================================="<<endl;
      }
};
int main() {
      student ob[20];
      int i=0,ch,r;
      while(true) {
            cout<<endl<<"    MAIN MENU ";
            cout<<endl<<"1. Enter Admission Info";
            cout<<endl<<"2. Enter Marks";
            cout<<endl<<"3. Prepare Marks Sheet";
            cout<<endl<<"4. No. of Students taken Admission";
            cout<<endl<<"5. Exit";
            cout<<endl<<"Enter your choice : ";
            cin>>ch;
            switch(ch) {
                  case 1: {
                        int fl=0;
                        cout<<endl<<"Enter Roll No : ";
                        cin>>r;
                        for(int j=0;j<=i;j++) {
                              if(ob[j].roll==r) {
                                    fl=1;
                                    break;
                              }
                        }
                        if(fl==1)
                              cout<<endl<<"Duplicate entry not allowed"<<endl;
                        else {
                              ob[i].roll=r;
                              ob[i].get_dt();
                              i++;
                        }
                  }break;
                  case 2: {
                        cout<<endl<<"Enter Roll No : ";
                        cin>>r;
                        for(int j=0;j<=i;j++) {
                              if(ob[j].roll==r) {
                                    ob[j].recv_marks();
                                    break;
                              }
                              else
                                    r=-1;
                        }
                        if(r<0)
                              cout<<endl<<"Roll No not Found"<<endl;
                  }break;
                  case 3: {
                        cout<<endl<<"Enter Roll No : ";
                        cin>>r;
                        for(int j=0;j<=i;j++) {
                              if(ob[j].roll==r) {
                                    ob[j].prep();
                                    break;
                              }
                              else
                                    r=-1;
                        }
                        if(r<0)
                              cout<<endl<<"Roll No not Found"<<endl;         
                  }break;
                  case 4: {
                        cout<<endl<<"No. of Student taken Admission : "
<<i<<endl;
                  }break;
                  case 5: {
                        exit(0);
                  }break;
                  default: {
                        cout<<endl<<"INVALID CHOICE"<<endl;
                  }
            }    
      }    
}          



Output :

MAIN MENU
1.  Enter Admission Info
2.  Enter Marks
3.  Prepare Marks Sheet
4.  No. of Students taken Admission
5.  Exit
Enter your choice : 1

Enter Roll No : 1
Enter Name : Rakesh
Enter Course : BCA
Enter Admission Date : 01/06/2009

MAIN MENU
1.  Enter Admission Info
2.  Enter Marks
3.  Prepare Marks Sheet
4.  No. of Students taken Admission
5.  Exit
Enter your choice : 2

Enter Roll No : 1
Enter Marks for English : 78
Enter Marks for Bengali : 67
Enter Marks for Maths : 80
Enter Marks for Science : 75
Enter Marks for Computer : 95

MAIN MENU
1.  Enter Admission Info
2.  Enter Marks
3.  Prepare Marks Sheet
4.  No. of Students taken Admission
5.  Exit
Enter your choice : 3

Enter Roll No : 1

Roll No              : 1
Name of Student      : Rakesh
Course               : BCA
Admission Date       : 01/06/2009
==================================
Subject              Marks
English                 78
Bengali                 67
  Maths                 80
Science                 75
Computer                95
==================================
Total                  395
==================================

MAIN MENU
1.  Enter Admission Info
2.  Enter Marks
3.  Prepare Marks Sheet
4.  No. of Students taken Admission
5.  Exit
Enter your choice : 4

No. of Student taken Admission : 1

No comments:

Post a Comment