Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CountS{
- public static void main(String[] args){
- Scanner kb = new Scanner(System.in);
- System.out.print("Enter a word: ");
- String word = kb.next();
- int sCount = 0;
- for(int i = 0; i < word.length(); i++){
- String letter = word.substring(i,i+1);
- if( letter.equals("s") ) sCount++;
- }
- System.out.print("There are " + sCount + " s's");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement