BOARD PATTERN QUESTIONS: Long Answer Questions (4 marks) Q1. Define a class employee with the following specifications; Private members of class employee : empno integer ename 20 characters basic,hra,da float netpay float calculate( ) A function to calculate basic + hra + da with float return type Public member functions of class employee : havedata( ) function to accept values for empno, sname, basic , hra ,da and invoke calculate( ) to calculate netpay dispdata( ) function to display all the data members on the screen . Ans. class employee { int empno; char ename[20]; float basic,da,hra; float netpay; float calculate( ) { return (basic + da + hra); } public : void havedata( ) { cout << employee ”Enter no”; cin >> empno; cout << Enter name ”\n “; cin >> ename; cout << Enter basic ”\n cin >> basic; salary”; cout << Enter DA ”\n “; cin >> da; cout << Enter HRA “\n “; cin >> hra; netpay = calculate( ); } void dispdata( ) { cout << Employee no is << endl ; “\n “<< empno cout << Name is << ename << endl ; “\n “ cout << Basic << basic << endl ; “\n Salary is” cout << DA is << endl ; “\n “ cout << HRA is << hra << endl ; “\n “ cout << Netpay is << netpay << endl ; “\n “ } } ; Q2. Define a class Student for the following specifications : Private members of the Student are : roll _ no integer name array of characters of size 20
BOARD PATTERN QUESTIONS: Long Answer Questions (4 marks) Q1. Define a class employee with the following specifications; Private members of class employee : empno integer ename 20 characters basic,hra,da float netpay float calculate( ) A function to calculate basic + hra + da with float return type Public member functions of class employee : havedata( ) function to accept values for empno, sname, basic , hra ,da and invoke calculate( ) to calculate netpay dispdata( ) function to display all the data members on the screen . Ans. class employee { int empno; char ename[20]; float basic,da,hra; float netpay; float calculate( ) { return (basic + da + hra); } public : void havedata( ) { cout << ”Enter employee no”; cin >> empno; cout << ”\n Enter name “; cin >> ename; cout << ”\n Enter basic salary”; cin >> basic; cout << ”\n Enter DA “; cin >> da; cout << “\n Enter HRA “; cin >> hra; netpay = calculate( ); } void dispdata( ) { cout << “\n Employee no is “<< empno << endl ; cout << “\n Name is “ << ename << endl ; cout << “\n Basic Salary is” << basic << endl ; cout << “\n DA is “ << endl ; cout << “\n HRA is “ << hra << endl ; cout << “\n Netpay is “ << netpay << endl ; } } ; Q2. Define a class Student for the following specifications : Private members of the Student are : roll _ no integer name array of characters of size 20
602211166compt_sci.docx