Page 272 - Computer science 868 Class 12
P. 272

void display()               :    to display the elements of the array
                     Specify the class Mixer, giving details of the constructor(int), Mixer(int), void accept(), Mixer mix(Mixer) and void display(). Define
                    the main() function to create an object and call the function accordingly to enable the task.
                  9.  A disarium number is a number in which the sum of the digits to the power of their respective position is equal to the number itself.
                                 1
                     Example: 135 = 1  + 3  + 5 3
                                     2
                     Hence, 135 is a disarium number.
                     Design a class Disarium to check if a given number is a disarium number or not. Some of the members of the class are given below.
                     Class name                   :    Disarium
                     Data Members/Instance variables
                     int num                      :    stores the number
                     int size                     :    stores the size of the number
                     Member Methods/Member functions
                     Disarium (int nn)            :    parameterised constructor to initialise the data members n = nn and size = 0
                     void countDigit()            :    counts the total number of digits and assigns it to size
                     int sumofDigits (int n, int p)   :   returns  the  sum  of  the  digits  of  the  number(n)  to  the  power  of  their  respective
                                                      positions (p) using recursive technique
                     void check()                 :   checks whether the number is a disarium number and displays the result with an
                                                      appropriate message
                     Specify the class Disarium giving the details of the constructor(), void countDigit(), int sumofDigits(int, int) and void check().
                    Define the main() function to create an object and call the functions accordingly to enable the task.
                 10.  A class Shift contains a two-dimensional integer array of order (m×n) where the maximum values of both m and n are 5. Design
                    the class Shift to shuffle the matrix (i.e., the first row becomes the last, the second row becomes the first and so on). The details
                    of the members of the class are given below.
                     Class name                   :    Shift
                     Data Members/Instance variables
                     mat[][]                      :    stores the array element
                     m                            :    integer to store the number of rows
                     n                            :    integer to store the number of columns
                     Member Functions/Methods
                     Shift(int mm, int nn)        :    parameterised constructor to initialise the data members m=mm and n=nn
                     void input()                 :    enters the elements of the array
                     void cyclic(Shift p)         :   enables the matrix of the object (P) to shift each row upwards in a cyclic manner and
                                                      store the resultant matrix in the current object
                     void display()               :    displays the matrix elements
                     Specify the class Shift giving details of the constructor(), void input(), void cyclic(Shift) and void display(). Define the main()
                    function to create an object and call the methods accordingly to enable the task of shifting the array elements.
                 11.  A class DeciOct has been defined to convert a decimal number into its equivalent octal number. Some of the members of the class
                    are given below.
                     Class name                   :    DeciOct
                     Data Members/Instance variables
                     n                            :    stores the decimal number
                     oct                          :    stores the octal equivalent number
                     Member Functions
                     DeciOct()                    :    constructor to initialise the data members n = 0, oct = 0
                     void getnum(int nn)          :    assign nn to n
                     void deci_oct()              :    calculates the octal equivalent of ‘n’ and stores it in oct using the recursive technique
                     void show()                  :   displays the decimal number ‘n’, calls the function deci_oct() and displays its octal
                                                      equivalent
                     Specify the class DeciOct giving details of the constructor(), void getnum(int), void deci_oct() and void show(). Also, define a
                    main() function to create an object and call the functions accordingly to enable the task.




                270270  Touchpad Computer Science-XII
   267   268   269   270   271   272   273   274   275   276   277