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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!