COMPUTER SCIENCE CLASS AND OBJECTS

Public members:
ReadData( ): Function accepts the data values and invoke the calculate function.
DisplayData( ):Function prints the data on the screen.

class Teacher
{ char Name[20];
char subject[10];
float Basic,DA,HRA,Salary;
float Calculate( )
{ Salary=Basic+DA+HRA;
return Salary;
}
public:
void ReadData( )
{ cout<<"\nEnter Basic, Dearness Allowance and “;
cout<<” House Rent Allowance: ";
cin>>Basic>>DA>>HRA;
Calculate();
}
void DisplayData( )
{ cout<<"\nThe Basic : "<<Basic;
cout<<"\nThe Dearness Allowance: "<<DA;
cout<<"\nThe House Rent Allowance: "<<HRA;
cout<<"\nThe Salary: "<<Salary;
}
};

1998 Annual:

2.b) Define a class student with the following specifications:

Private members of class student:

Admno   integer
Sname   20 character
English   float
Math        float
Science  float
Total        float
Ctotal( ) A function to
calculate English + math + science with float return type

Public member functions of class student:
Takedata( ):Function to accept values for admno,sname, English, math, science and invoke ctotal to calculate total.
Showdata( ):Function to display all the data members on the screen.

class student
{ int Admno;
char Sname[20];
float English,Math,Science,Total;
float Ctotal()
{ Total=English+math+science;
return Total;
}
public:
void Takedata()
{ cout<<”\nEnter the admission number,name of the student: “;
cin>>Admno;
gets(sname);
cout<<”\nEnter English, Maths, Science Marks: “;
cin>>English>>Math>>Science;
Ctotal( );
}
void Showdata( ){ cout<<”\nThe admission number of the student: “<<Admno;
cout<<”\nThe name of the student: “<<Sname;
cout<<”\nEnglish , Maths and Science Marks are…”;
cout<<english<<”\t”<<math<<”\t” <<science<<”\n”;
cout<<”\nTotal marks of the student: “<<Total;
};

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object7.php on line 153

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object7.php on line 153

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object7.php on line 155

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/calss_object7.php on line 155