Page 237 - CA_Blue( J )_Class9
P. 237

8.   Write a program to input a number and print whether the number is a Niven number or not. A Niven number is
                        divisible by the sum of the digits.
                       Example: 111 because 1+1+1= 3, and 111 is divisible by 3.
                    9.   Write a program to input a number and check whether it is an Automorphic number or not. An Automorphic number
                        is a number whose square ends in the same digits as the original number.
                       Example: 76 = 762 = 5776, so last 2 digits 76 is same as the original number.
                   10.  Write a menu-driven program to print the following series according to user’s choice using switch case statement.
                        a.  s=1 + 12 + 123  + 1234+ 12345.
                        b.  p= 1/1*  2/4*  3/9*…*nth term
                    11.   Write a menu-driven program to input n and print the sum of the following series:
                                2
                                      3
                        a.  s = x+ x /2! + x /3! + ……. n
                                3
                                            3
                                      3
                        b.  s =  1/1  –  1/2   +  1/3 ………….1/n 3
                    12.   Write a menu-driven program to perform the following (use switch case statement):
                        a.  To print the series 0, 3, 7, 15, 24, … n terms (value of ‘n’ is to be an input by the user)
                        b.  To find the sum of the series given below:
                                S = 1 / 2 + 3 / 4 + 5 / 6 + 7 / 8 + … + 19 / 20.
                    13.   Write a program to input a number and print whether the number is a Duck Number or not.
                       Duck number: A Duck number is a number that has at least one zero present in it.
                       For example, 3210, 7056, and 8430709 are all duck numbers
                    14.   Using the switch statement, write a menu-driven program to:
                       a.   To find and display all the factors of a number input by the user (including 1 and excluding the number itself).
                            Example:
                           INPUT:     n = 15
                            OUTPUT: 1, 3, 5
                        b.     To find and display the factorial of a number input by the user. The factorial of a non-negative integer n, denoted
                           by n!, is the product of all integers less than or equal to n.
                            Example:
                           INPUT: n = 5
                            OUTPUT: 5! = 1 × 2 × 3 × 4 × 5 = 120.
                        For an incorrect choice, an appropriate error message should be displayed.
                    15.   Write a program to input a number and find the smallest digit in the number.
                       Sample Input: 6524
                       Output: Smallest digit is 2.
                    16.   Using a switch statement, write a menu-driven program to:
                       a.   Generate and display the first "n” terms of the Fibonacci series
                              0, 1, 1, 2, 3, 5……nth term
                              The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.
                       b.   Find the product of the even digits of an integer that is input.
                            Sample Input : 29485
                            Sample Output: Product of the digits = 64
                       For an incorrect choice, an appropriate error message should be displayed.
                    17.   Write a program to input n whole numbers and do the following tasks:
                       a.  Find the number of positive numbers.
                       b.  Add the negative numbers.
                    18.   Write a program to accept a number and check whether it is a Trimorphic number. A Trimorphic number is a number
                        which is contained in the last digit(s) of its cube.
                        Example: 6 is a trimorphic number as its cube is 216 and 6 is present as the last digit of 216.





                                                                                       Iterative Constructs in Java  235
   232   233   234   235   236   237   238   239   240   241   242