Page 405 - computer science (868) class 11
P. 405
Some of the members of the class are given below:
Class name : Count
Data Members/Instance variables
line : To store any sentence
Member Methods/Member functions
Count() : Default constructor
void input() : Accepts sentence in variable line
int cal(String s) : Using recursive technique, counts and returns how many times ‘and’ or ‘And’ or
‘AND’ occur in the sentence
void print() : Calls int cal(String) and prints the frequency with an appropriate message
Specify the class Count giving details of the constructor, void input(), int cal(String) and void print(). Define the main() method to
create an object and call the member functions accordingly to enable the task.
9. An array contains Computer Science marks of 50 students of a class. The teacher wants to know how many students of his class
have got 90 and above in his subject. A class Marks is defined to do the same.
Some of the members of the class are given below:
Class name : Marks
Data Nembers/Instance variables
mark[] : An array to store computer marks of 50 students in a class
Member Methods/Member functions
Mark() : Default constructor to initialise the array to 0
void input() : Accepts marks in mark[] of 50 students
int count(int p) : Using recursive technique, counts and returns how many students have got 90%
and above. Here parameters ‘p’ denotes the index position of the array.
void print() : Calls count(int) and prints the array along with the frequency.
Specify the class Marks giving details of the constructor, void input(), int count(int) and void print(). Define the main() method to
create an object and call the member functions accordingly to enable the task.
10. A class Transpose is defined to generate the transpose of a matrix. The transpose of a matrix is obtained by interchanging its rows
into columns and columns into rows. For example,
1 2 3
If size=3 and matrix a[][] is 4 5 6
7 8 9
1 4 7
then, its transpose b[][] will be 2 5 8
3 6 9
Some of the members of the class are given below:
Class name : Transpose
Data Members/Instance variables
s : Integer to store size of the matrix
a[][] : Integer two-dimensional matrix
b[][] : Integer matrix to store the transpose of a[][]
Member Methods/Member functions
Transpose(int ss) : Initialises s to ss and declares the matrix
void input() : Accepts numbers in matrix a[][]
void generate(int r, int c) : Using recursive technique, generates the transpose matrix in b[][]. Here parameters
‘r’ and ‘c’ denote row and column position respectively
void print() : Calls generate(int,int) and then prints the transpose matrix b[][]
Specify the class Transpose giving details of the constructor, void input(), int generate(int, int) and void print(). Define the main()
method to create an object and call the member functions accordingly to enable the task.
403
Recursion 403

