Posts

Showing posts from July, 2021

FIND FREQUENCY OF A PARTICULAR CHARACTER IN A GIVEN SENTENCE

 FIND FREQUENCY OF A PARTICULAR CHARACTER IN A GIVEN SENTENCE I/P: hi hello how are you h O/P: 3 PROGRAM: package   S trings ; import   java . util .*; class   FrequencyforparticularCharacter {      public   static   void   main ( String   args [])     {          Scanner   sc = new   Scanner ( System . in );          String   s1 = sc . nextLine ();          char   c = sc . next (). charAt ( 0 );          String   arr []= s1 . split ( " " );          ArrayList < Character >  al = new   ArrayList <>();          for ( int   i = 0 ; i < arr . length ; i ++)         {  ...

LESS THAN PATTERN

 LESS THAN PATTERN  I/P: 3 O/P: 1     2         3     4 5 PROGRAM: import   java . util .*; public   class   LessThan  {      public   static   void   main ( String   args [])     {          Scanner   sc = new   Scanner ( System . in );          int   iNum = sc . nextInt ();          int   count = 0 ;          for ( int   i = 1 ; i <= iNum ; i ++)         {              for ( int   j = 1 ; j <= i ; j ++)             {                ...

STRING REVERSE PATTERN

  STRING REVERSE PATTERN I/P: HARRY O/P: Y R R A H Y R R A Y R R Y R Y PROGRAM: import   java . util .*; public   class   HarryPattern  {      public   static   void   main ( String   args [])     {          Scanner   sc = new   Scanner ( System . in );          String   s1 = sc . next ();          for ( int   i = 0 ; i < s1 . length (); i ++)         {              for ( int   j = s1 . length ()- 1 ; j >= i ; j --)             {                  System . out . print ( s1 . charAt ( j )+ " " );    ...

INNER SQUARE PATTERN

 INNER SQUARE PATTERN I/P: 4 O/P: 1   1  2 2  3 3 4   4 PROGRAM: import   java . util .*; class   InnerSquarePattern {      public   static   void   main ( String   args [])     {          Scanner   sc = new   Scanner ( System . in );          int   iNum = sc . nextInt ();          for ( int   i = 1 ; i <= iNum ; i ++)         {             if ( i == 1  ||  i == iNum )            {                 for ( int   j = 1 ; j <= iNum ; j ++)            ...

PATTERN PROGRAMS

 PATTERN PROGRAMS  I/P: 4 O/P: 14 16 18 20 8 10 12 4 6 2 PROGRAM: import   java . util .*; class   Fourteen16 {      public   static   void   main ( String   args [])     {          Scanner   sc = new   Scanner ( System . in );          int   iNum = sc . nextInt ();          ArrayList < Integer >  al = new   ArrayList <>();          int   a = 2 ;          for ( int   i = 1 ; i <= iNum ; i ++)         {              for ( int   j = iNum ; j >= i ; j --)             {      ...

Check the given line consists of palindrome or not

 Check the given line consists of palindrome or not i/p: I want malayalam movie o/p: Present program: import   java . util .*; public   class   PalindromePresentInALineOrNot  {      public   static   boolean   isCheck ( String   s2 )     {         StringBuffer   sb = new   StringBuffer ( s2 );         sb . reverse ();         if ( s2 . equals ( String . valueOf ( sb )))        {            return   true ;        }         return   false ;     }      public   static   void   main ( String []  args ) {         Scanner   sc = ne...

a2b4c Pattern Program

 a2b4c Pattern Program i/p: 5 o/p: a 2 b 4 c 2 b 4 c b 4 c 4 c c 4 c b 4 c 2 b 4 c a 2 b 4 c PROGRAM: import  java.util.*; class   a2b4c {      public   static   void   main ( String   args [])     {          Scanner   sc = new   Scanner ( System . in );          int   iNum = sc . nextInt ();          ArrayList < String >  al = new   ArrayList <>();          int   a = 97 ;          int   b = 2 ;          for ( int   i = 0 ;i<iNum;i++)         {              if (i% 2 == 0 )         ...