Click here to Skip to main content
15,041,391 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:

C#
//count letters ,words ,sentences
package sentence1java;
import java.util.Scanner;
public class main {
    public static void main(String[] args) {
       
     Scanner input=new Scanner(System.in);  
        System.out.println("enter an expression:");
        int word=0;
        int letter=0;
        int sentence=0;
        String s;
        int i=0;
        s=input.nextLine();
        while(i<s.length()){
            i++;
        }
            if (s.charAt(i) == '.') {
                sentence++;
                
            if (s.charAt(i) != '.') {
                    
         System.out.println("sentence:");
           if (s.charAt(i) == '') {
                word++;
          if (s.charAt(i) != '') {
         System.out.println("word:");
          if (s.charAt(i) != '.'+' ') {
                              letter++;
                                  
         System.out.println("letter:");
                          }
                  )
                  )

the program want sentences from us after then the program most count the numbers of letters , words , sentences.
Posted
Updated 21-Jan-10 0:10am
v4

1 solution

mf_arian wrote:
the program want sentences from us


Try entering this.
The quick brown fox jumps over the lazy dog. 
The quick brown fox jumps over the lazy dog. 
The quick brown fox jumps over the lazy dog.

:doh: :doh: :doh:
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900