Page 430 - Cs_withBlue_J_C11_Flipbook
P. 430

int sumfact(int x)               :  Calls  method  int factorial(int)  and using  recursive  technique  calculates  and
                                                         returns the sum of factorial of the digits of number ‘X’
                     void check()                     :  Calls int sumfact(int x) and checks if the given number is a Krishnamurthy number
                                                         or not
                     Specify the class Kmurthy giving details of the methods void getnum(), int factorial(int) and int sumfact(int) and void check(). Also,
                    define the main() function to create an object and call the functions accordingly to enable the task.
                  4.  Monodigit numbers are the numbers consisting of a single repeating digit, e.g., 77, 999, 8888, etc.
                     A class called Mono is defined to check if a given number is monodigit number or not. The detail of the class is given below:
                     Class name                       :   Mono
                     Data Members/Instance variables
                     num                              :   To store the number
                     Member Methods/Member functions
                     void getnum()                    :   Accepts number in num from the user
                     boolean check(int n, int d)      :  Using recursive technique, checks if the number ‘n’ whose last digit is ‘d’ is a
                                                         mono digit number or not and returns true or false accordingly
                     void print()                     :   Calls boolean check(int,int) and prints appropriate message
                     Specify the class Mono giving details of the methods void getnum(), boolean check(int, int) and void print(). Also, define the
                    main() function to create an object and call the functions accordingly to enable the task.
                  5.  A class CalSeries has been defined to calculate the sum of the following series.
                                   3
                               2
                     sum = 1 + x + x  + x  +......x n
                     Some of the members of the class are given below:                                         [ISC 2022]
                     Class name                       :   CalSeries
                     Data Members/Instance variables
                     x                                :   Integer to store the value of x
                     n                                :   Integer to store the value of n
                     sum                              :   Integer to store the sum of the series
                     Member Methods/Member functions
                     Calseries()                      :   Default constructor
                     void input()                     :  Accepts the value of x and n respectively
                                                                                     q
                     int power(int p, int q)          :   Returns the power of p raised to q (p ) using the recursive technique
                     void cal()                       :  Calculates the sum of the series by invoking the method power(), and displays
                                                         the result with an appropriate message
                     Specify the class CalSeries giving details of the constructor, void input(), int power(int, int) and void cal(). Define the main()
                    method to create an object and call the member functions accordingly to enable the task.
                  6.  A class ToWord is defined to print the digits of a number in words. Example
                     1567 will be printed as ONE FIVE SIX SEVEN
                     298 will be printed as TWO NINE EIGHT, etc.
                     Some of the members of the class are given below:
                     Class name                       :   ToWord
                     Data Members/Instance variables
                     num                              :   Integer to store the value of num
                     Member Methods/Member functions
                     ToWord()                         :   Default constructor
                     void input()                     :   Accepts the value of num
                     void print(int n)                :  Prints the digits of the numbers in word using the recursive technique
                     Specify the class ToWord giving details of the constructor, void input(), void print(int). Define the main() method to create an
                    object and call the member functions accordingly to enable the task.





             428 428  Touchpad Computer Science-XI
   425   426   427   428   429   430   431   432   433   434   435