Question
I am trying to create a letter counter program that simply counts occurences of a character in a string. I am unsure why the code
I am trying to create a letter counter program that simply counts occurences of a character in a string. I am unsure why the code is not compiling. If you could just fix and explain, it would be much appreciated.
import java.util.*;
public class LetterCounterPC5 { public static void main(String{} args) { //variable declaration int count = 0; String inputstring; String str; char character; //create a scanner class Scanner keyboard = new Scanner(System.in); //user enters string System.out.println("Enter a string"); //read string inputstring = keyboard.nextLine(); //user enters char System.out.println("Enter a character"); //read char str = keyboard.nextLine(); character=str.charAt(0); //loop to find frequency of char in string for(int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started