/*
   This program demonstrates some uses of Java's
   built in String class.
*/
import jpb.*;

public class TestString
{
   public static void main( String[] args )
   {
    // Ask the user to input a string.
    SimpleIO.prompt("Please enter a string of characters: ");
    String userInput = SimpleIO.readLine();

    // Now use methods from the String class to
    // manipulate the string.
    System.out.println( "\nThe value of userInput.length() is: "
                        + userInput.length() );

    System.out.println( "\nThe result of userInput.toUpperCase() is: "
                        + userInput.toUpperCase() );

    System.out.println( "\nThe result of userInput.trim() is: "
                        + userInput.trim() );

    System.out.println( "\nThe result of userInput.indexOf( \"a\" ) is: "
                        + userInput.indexOf( "a" ) );

    System.out.println( "\nThe result of userInput.lastIndexOf( \"a\" ) is: "
                        + userInput.lastIndexOf( "a" ) );
    // What happens in the last two examples if the string does not
    // contain the character `a`?

    System.out.println( "\nThe result of userInput.substring(2, 10) is: "
                        + userInput.substring(2, 10) );
    // What happens if the string has less than 10 characters?

    System.out.println( "\nThe result of userInput.charAt( 15 ) is: "
                        + userInput.charAt( 15 ) );
    // What happens if the string has less than 15 characters?

   }//main
}//TestString