THINK FIRST·CODE LATER

← All labs

Words report from text

Problem

Write a class WordReport that reads one line of text and prints a small report:

Words: 5
Longest: programming
Capitalised: Java Is A Fun Language
  • Words counts the words (separated by spaces);
  • Longest is the longest word (the first one, if several have the same length);
  • Capitalised prints the sentence with every word starting with a capital letter.

Use split(" ") and StringBuilder.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.