Page 539 - Cs_withBlue_J_C11_Flipbook
P. 539

Frequency of consonants: 5
                 Original word: COMPUTER
                 Rearranged word: OUECMPTR


                                                            Variable Description
                   NAME         TYPE                                       DESCRIPTION
                  word       string       To store the word from the user
                  newword    string       To store the rearranged words

                  ch         char         To store the extracted character
                  vc         int          Number of vowels
                  cc         int          Number of consonants
                  v          String       To store the vowels

                  c          String       To store the consonants




                   Program 20    A number is said to be Bouncy number if the digits of the number are unsorted.
                                 For example,
                                 22344    :   It is not a Bouncy number because the digits are sorted in ascending order.
                                 774410   :   It is not a Bouncy number because the digits are sorted in descending order.
                                 155349  :   It is a Bouncy number because the digits are unsorted.
                                 A number below 100 can never be a Bouncy number.
                                 Write a program in Java to accept a number. Check and display whether it is a Bouncy number
                                 or not.


                   1       import java.util.*;
                   2       class BouncyNumber
                   3       {

                   4           public static void main()

                   5           {
                   6               int num,before,rem,temp;
                   7               boolean incre = true, decre = true;

                   8               Scanner in = new Scanner(System.in);
                   9               System.out.print("Enter a number: ");

                   10              num = in.nextInt();
                   11              if (num > 100)

                   12              {
                   13                  temp = num;

                   14                  before = temp % 10;
                   15                  while (temp != 0)

                   16                  {


                                                                                                                       537
                                                                                                   Internal Assessment  537
   534   535   536   537   538   539   540   541   542   543   544