Jump to content
×
×
  • Create New...

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

  • Bu Alana Reklam Verebilirsiniz
    Bu Alana Reklam Verebilirsiniz

Girilen Cümledeki Kelime Sayısını Bulan Program Örneği ve Kodu | Java

Rate this topic


serverIR
 Share


Recommended Posts

Girilen Cümledeki Kelime Sayısını Bulan Program Örneği ve Kodu | Java
 Share


  • Members

Bu örnekte Java ile bir metnin kaç kelimeden oluştuğunu bulmak için gerekli kodları paylaşacağım.

 

Örneğimizde kelimeSay isimli fonksiyon merindeki boşluklar sayesinde cümldeki kelime sayısını bulup döndürüyor.

Anaprogramda girilen metin fonksiyona gönderilerek dönen değer kelime sayısı olarak yazdırılıyor.

Java Kodları:

 

package kelime.sayici;
 
/**
 *
 * @author yazilimkodlama.com
 */
public class KelimeSayici {
 
    static int kelimeSay(String string)  
        {  
          int count=0;  
      
            char ch[]= new char[string.length()];     
            for(int i=0;i<string.length();i++)  
            {  
                ch[i]= string.charAt(i);  
                if( ((i>0)&&(ch[i]!=' ')&&(ch[i-1]==' ')) || ((ch[0]!=' ')&&(i==0)) )  
                    count++;  
            }  
            return count;  
        }  
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
         String string ="Java örnekleri yazilimkodlama";  
         System.out.println(kelimeSay(string) + " kelime.");
    }
    
}

 

Ekran Çıktısı:

 

resim_2022-04-26_050549970.png

----------------------------------------------------------------------------

Link to comment
Share on other sites


Konu Altı Reklam 1
Konu Altı Reklam 2
  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • Create New...