Question: Write a complete Java program called CharCounter that gets a two Strings called word and character from the user at the command line and then

Write a complete Java program called CharCounter that gets a two Strings called word and character from the user at the command line and then counts the occurrences of character in word. Check that character has a length of 1, and then extract the char. Use a while loop to check each position in the word String variable and return the number of times the char occurs. For example, if word is "test" and character is "e" you would output: "There is 1 occurrence of e in test."

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!