Advertisement
scaawt

Lab08

Sep 26th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package CSCE145;
  2.  
  3. // written by --
  4. import java.util.Scanner;
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner keyboard = new Scanner(System.in);
  9.         System.out.println("Welcome to the Letter Counter Program! First enter a phrase and then " +
  10.                 "press ENTER and then enter a letter to be counted and press ENTER again.");
  11.         String word = keyboard.nextLine();
  12.         String letter = keyboard.nextLine();
  13.         int sz = word.length();
  14.         char c = word.charAt(6);
  15.  
  16.         for (int i = 0; i < word.length(); i++) {
  17.         if (Character.isLetter(word.charAt(i)))
  18.             sz++; }
  19.  
  20.             System.out.println(sz + letter + "letters in your phrase");
  21.  
  22.         }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement