Skip to content

Instantly share code, notes, and snippets.

@arielmagbanua
Created September 17, 2021 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielmagbanua/bf7a0fbf54fbe12b50bb16bad2173b69 to your computer and use it in GitHub Desktop.
Save arielmagbanua/bf7a0fbf54fbe12b50bb16bad2173b69 to your computer and use it in GitHub Desktop.
Character Counter

Character Counter

Write a Java program that counts a character from the input string.

Starter Code

public class App {
    public static void main(String[] args) throws Exception {
        // scanner
        Scanner scanner = new Scanner(System.in);

        // get the input string
        
        // get the character to count

        // count the characters

        // print the result
        
        scanner.close();
    }
}

Output

Enter a string: The Quick BROWN Fox
Enter the character to count: x
x = 1
Enter a string: Hello GALAXY!!!
Enter the character to count: l
l = 3
Enter a string: Hello World!!!
Enter the character to count: !
l = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment