Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CSCE145;
- // written by --
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- System.out.println("Welcome to the Letter Counter Program! First enter a phrase and then " +
- "press ENTER and then enter a letter to be counted and press ENTER again.");
- String word = keyboard.nextLine();
- String letter = keyboard.nextLine();
- int sz = word.length();
- char c = word.charAt(6);
- for (int i = 0; i < word.length(); i++) {
- if (Character.isLetter(word.charAt(i)))
- sz++; }
- System.out.println(sz + letter + "letters in your phrase");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement