about | help | code help+videos | done | prefs |
Write a method that returns the number of times that 'find' appears in 'str'. As a precondition, you may assume that 'find' is exactly one character long. For this problem you may use any "normal" code you want to, but you are ONLY allowed to use certain string methods. The ONLY string methods you are allowed to use are: .length, .charAt, .substring, and .equals. You might not need all of these methods, but you are NOT allowed to use any other string methods. For example, you may not use the .toUpperCase method. Recursion IS allowed, but not required. test2024_01_22_APP1SLHL_countChar("Hear the sledges with the bells - Silver bells! What a world of merriment their melody foretells! How they tinkle, tinkle, tinkle, In their icy air of night! While the stars, that oversprinkle All the heavens, seem to twinkle With a crystalline delight; Keeping time, time, time, In a sort of Runic rhyme, To the tintinnabulation that so musically wells From the bells, bells, bells, bells, Bells, bells, bells - From the jingling and the tinkling of the bells.", "b") → 10 test2024_01_22_APP1SLHL_countChar("AAAaaAAAaAAA", "a") → 3 test2024_01_22_APP1SLHL_countChar("This is a test", "i") → 2 ...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