Title Case

Lab Java Intermediate 20 points

Read a line of words and print it with each word capitalised (first letter upper case, rest lower case), words separated by single spaces.

Input

One line.

Output

One line.

Example

Input

hELLO   wORLD from JAVA

Output

Hello World From Java
Sample input available Sample output available
Editor
Java

Hints

Split into words, then rebuild them.

Solution explanation

Splitting, transforming and re-joining is a common text-processing pattern.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] words = sc.nextLine().trim().split("\\s+");
        StringBuilder sb = new StringBuilder();
        for (String w : words) {
            if (sb.length() > 0) {
                sb.append(' ');
            }
            sb.append(Character.toUpperCase(w.charAt(0))).append(w.substring(1).toLowerCase());
        }
        System.out.println(sb);
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD