Page 315 - CA_Blue( J )_Class10
P. 315

19                  System.out.print(" , " + c);
                  20                  a=b;

                  21                  b=c;
                  22              }

                  23          }
                  24      }

                  25      public static void main()
                  26      {

                  27          Scanner sc= new Scanner(System.in);
                  28          int n;

                  29          System.out.println("Enter the last term of the Fibonacci series : ");
                  30          n= sc.nextInt();
                  31          fibo ob = new fibo();

                  32          ob.accept(n);

                  33          ob.print();
                  34      }
                  35  }

                 You will get the following output:












                                 To define a class sentence with the following specifications:
                  Program 6      Data Members
                                 String sen          :  To input the sentence
                                 String word         :   To input the word
                                 int count           :  To count words
                                 Methods
                                 sentence()          :  Constructor to assign default values to data members
                                 void input()        :  Inputs the sentence and word
                                 void check()        :   checks how many times the word is there in sentence and stores in
                                                        count.
                                 void display()      :  Displays the count data member


                   1  import java.util.*;
                   2  class sentence

                   3  {




                                                                                                                       313
                                                                                                         Constructors  313
   310   311   312   313   314   315   316   317   318   319   320