Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  ss
Language: C/C++
Code:
# include<iostream>
using namespace std;
class student
{
     public:
     char name[30];
     int rollno;
     float c,m,n;
          student()
          {
               m=m1;
               n=m2;
          }
          void getdata()
          {
               cout<<"enter the name";
               cin>>name;
               cout<<"enter the rollno";
               cin>>rollno;
          }
          void calculate()
          {
               try
               {
                    if(m!=0)
                    {
                         c=(((m+n)/200)*80);
                         cout<<"the cutoff mark is"<<c;
                    }
                    else
                         throw m;
               }
               catch(int i)
               cout<<"exception caught";
          }
          ~student()
          {
               cout<"destructor called";
          }
};
class sports
{
     public:
     int sm;
     char level[70];
     int ch;
     void getdata1()
          {
               cout<<"nenter the choice 1.nationaln 2.internationaln";
               cin>>ch;
               switch(ch)
               {
               case 1:                    sm=10;
                    break;
               case 2:
                    sm=20;
                    break;
               }
     
               
          }
          
};
class sportsstudents:public student,public sports
{
     
     public:
     float totcutoff;
          void calc()
          {
               totcutoff=sm+c;
               cout<<"total cutoff is"<<totcutoff;
          }
          void display()
          {
               cout<<"n name:"<<name<<"nrollno:"<<rollno<<"n";
          }
          
};
int main()
{
     int m1,m2;
     sportsstudents d1;
     cout<<"enter the maths and science mark";
     cin>>m1>>m2;
     d1.getdata();
     d1.display();
     d1.calculate();
     d1.getdata1();
     d1.calc();
     
     return 0;
}
     
          
Comments: