about | help | code help+videos | done | prefs |
Write a method that counts how many times 'ltr' occurs in 'str'. Note that 'ltr' is a string, but it will always contain exactly one character. The string 'str' may contain any number of characters. Return a string that states how many times 'ltr' occurs. That string must be grammatically correct, so if it occurs exactly once you must end with "1 time.", but for any other number of times it should say "X times." (where X is the number of times it occurs). Look at the test data for examples. test2021_04_22_APP1SLHL_countLtrs("This is a test", "t") → "The character t occurs 2 times." test2021_04_22_APP1SLHL_countLtrs("jagsdsdauiygugauhgdgadgdshdgsa", "g") → "The character g occurs 7 times." test2021_04_22_APP1SLHL_countLtrs("learning is so cool", "x") → "The character x occurs 0 times." ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy