Question
java: Complete the class LoopyText which has a constructor that takes a String of text (provided for you). Implement the following methods. public String getEverySecondCharacter()
java:
Complete the class LoopyText which has a constructor that takes a String of text (provided for you). Implement the following methods.
public String getEverySecondCharacter() gets a string consisting of every other character, starting with the character at index 0
public int upperCaseCount() gets the number of uppercase letters in the text. You can use the String contains method or the Character class' static method isUpperCase
A method called firstLetters that returns a string consisting of the first character of every word in the string. If the string is the empty string return the empty String. You can use indexOf (" ") to control the loop and to determine where a new word starts.
Provide Javadoc.
Use the following file:
LoopyTextTester.java
/** * Tests the methods of LoopyText. * @author Kathleen O'Brien */ public class LoopyTextTester { public static void main(String[] args) { LoopyText loopy = new LoopyText("Java for All"); System.out.println(loopy.upperCaseCount()); System.out.println("Expected: 2"); System.out.println(loopy.firstLetters()); System.out.println("Expected: JfA"); loopy = new LoopyText("Today is the First Day of the Rest of your LIFE!"); System.out.println(loopy.upperCaseCount()); System.out.println("Expected: 8"); System.out.println(loopy.firstLetters()); System.out.println("Expected: TitFDotRoyL"); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started