Develop a mark sheet in C++ for university examination with following data: a) Students’ name b) Enrolment no c) roll no d) Theory marks in 5 subjects e) Practical marks in five subjects f) grade Overload << and >> operator .Grade should be calculated for each subject. Use Constructor overloading. Roll no should be auto generated

 


#include<iostream>
#include<ctime>
using namespace std;
class marksheet
{
        char student_name[20];
        long int enroll;
        int rollno;
        int s[4];
        int p[4],t[4];

    public:

        marksheet(){};

        marksheet(char sn , long int en ,int rn)
        {
            student_name[20] = sn;
            enroll=en;
            rollno=rn;
        }

        void theory();
        void practical();
        void sum();
        void grade();
        friend istream & operator >>(istream &,marksheet &);
        friend ostream & operator <<(ostream &,marksheet &);
};

istream & operator >>(istream& in , marksheet &m)
{
    cout<<"enter the student name "<<endl;
    in>>m.student_name;

    cout<<"Enter theory marks of 5 subjects out of 70 : "<<endl;
    for (int i = 0i < 5i++)
    {
        in>>m.s[i];
    }

    cout<<"Enter practical marks of 5 subjects out of 30 : "<<endl;
    for (int i = 0i < 5i++)
    {
        in>>m.p[i];
    }

    cout<<"Enter enrollment no. :"<<endl;
    in>>m.enroll;
    return (in);
}

void marksheet :: sum()
{
   for (int i = 0i < 5i++)
   {
       t[i]=s[i]+p[i];
       cout<<"totol marks    : "<<t[i]<<endl;
   }

}

void marksheet :: grade ()
{
    for (int i = 0i < 5i++)
    {
        if(t[i]>=80)
        // ch='A';
        cout<<"grade = A"<<endl;
        else if(t[i]>=60)
        // ch='B';
        cout<<"grade = B"<<endl;
        else if(t[i]>=40)
        // ch='C';
        cout<<"grade = C"<<endl;
        else if(t[i]>=33)
        // ch='D';
        cout<<"grade = D"<<endl;
        else if(t[i]<33)
        // ch='f';
        cout<<"grade : FAIL"<<endl;
    }

}


ostream & operator <<(ostream & out , marksheet &m)
{
    m.rollno=rand()%100;
    out<<"student name    : "<<m.student_name<<endl;
    out<<"roll no         : "<<m.rollno<<endl;
    out<<"Enroll no.      : "<<m.enroll<<endl;
    return(out);
}

int main()
{
    srand(time(NULL));
    marksheet ms;
    cin>>ms;
    cout<<"\n\n*****************STUDENT INFO******************\n"<<endl;
    cout<<ms;
    ms.sum();
    ms.grade();
}

output :

enter the student name Rahul Enter theory marks of 5 subjects out of 70 : 20 30 40 50 60 Enter practical marks of 5 subjects out of 30 : 25 26 27 28 29 Enter enrollment no. : 27 roll no : 17 Enroll no. : 27
totol marks : 45 totol marks : 56 totol marks : 67 totol marks : 78 totol marks : 89 grade = c grade = C grade = B grade = B grade = A

Comments

Popular Post

Create a base class called shape .Use this class to store two double type values that could be used to compute the area of figures, Derive two specific classes called triangle and rectangle from the base shape .Add to the base class, a member function get_data() to initialise base class data members and another member function display_area() to compute and display the area of figures. Make display_area () as a virtual function and redefine this function in the derived class to suit their requirements. Using these three classes, design a program that will accept dimensions of a triangle or a rectangle interactively and display the area. Area of rectangle = x*y Area of triangle = ½*x*y

Assume that a bank maintains two kinds of accounts, are called as saving account and current account. The saving account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below the level, a service charge is imposed. Create a class account that stores customer name, account number and type of account. From this derive the classes cur_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks: a.Include constructor for all the three classes. b.Accept deposit amount from the customer and update the balance. c.Display the balance. d.Compute and deposit interest. e.Permit withdrawal and update the balance. f. Check for minimum balance, impose penalty, necessary and update the balance.

Define a class to represent a Bank Account. Include the following members: Data Members: i. Name of the depositor ii. Account number iii. Type of account iv. Balance amount in the account Member Functions: 1. To Input initial values 2. To deposit an amount 3. To withdraw an amount after checking the balance 4. To display name and balance Also write constructor for this class that takes four arguments. It should also handle type of account as savings by default