/* input a String and this program will count the occurrences of each letter. */ import java.util.*; // Scanner public class Prog6_23 { public static void main(String[] args) { Scanner in=new Scanner(System.in); System.out.print("Enter a String and I will tell you the number of occurrences of every letter "); String temp = in.nextLine(); int count; for(char c='a';c<='z';c++) // iterate for each lower case letter { count = countOccurrences(temp, c); // count number of times the lower case letter appears in the String if(count>0) System.out.println(c + " appears " + count + " times"); // if it appears, output how many times } } // iterate through the String and compare each lower case version of the letter at that indext to c, returning the count public static int countOccurrences(String temp, char c) { int count = 0; for(int i=0;i