This problem is asking for me to write a method in the SentenceCounter class tha
ID: 3737339 • Letter: T
Question
This problem is asking for me to write a method in the SentenceCounter class that will pass the test in the images above.
e's a Specific Blank? we're going to build is a method that, given an integer parameter, he next piece of heum, returns next pie , i r returns tnendblankNum s 2 , the method will return 11 If blankNur is 1, then this index of that blank in our String. For example, if our String is "This the same value as firstBlankPosition). Here is the test for this nevw as blanks ring method @Test public void testBlankPosition() assertEquals (10, scl.blankPosition (3)) assertEquals (24, sc2.blankPosition (4)); write the code, it's important that you really understand what blankPosition ) is Before you can Beluvoced to do. Be sure that you can explain why the tests are looking for the values in the suppose tEquals() calls. Write enough code to make this compile and watch it go RED. cearly, the blankPosition) method is going to require a loop to go through the String. As you prepare to write this loop, think about these things: . You need one variable to keep track of where you are in the string. . You need another variable to keep track of how many blanks you have seen. How should you stop the loop? t forrat to RFFACTOR.Explanation / Answer
//SentenceCounter.java public class SentenceCounter { private String s; public SentenceCounter(String s) { this.s = s; } public int countLowerCase(){ int count = 0; for(char ch: s.toCharArray()){ if(ch >='a' && chRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.