//PrintCapsOnly.java
//Reads in up to a full line of characters and then writes
//out only those which are capitals, in the same order.

import java.io.IOException;

public class PrintCapsOnly
{
    public static void main(String[] args) throws IOException
    {
        System.out.println
        (
            "\nThis program reads in up to a full line of "
            + "characters and then writes out the\ncapitals only, in the "
            + "same order they were entered.\n"
        );

        System.out.print("Enter the line of characters on the line below:\n");
        readCharsAndPrintCapsOnly();
        System.out.println();
    }

    /** Read a line of characters and print out only those that are
        capital letters, in the same order that they were entered.
        <p>Pre:<p>The input stream is empty.
        <p>Post:<p>A line of characers has been entered and the capital
        letters in that line have been written out in their original order.
    */
    public static void readCharsAndPrintCapsOnly() throws IOException
    {
        char ch = (char)System.in.read();
        if (ch != '\n')
        {
            if (ch >= 'A' && ch <= 'Z') System.out.print(ch);
            readCharsAndPrintCapsOnly();
        }
    }
}
