86
Code
/// Name: Josh Bautista
/// Period: 6
/// Program Name: Letter At A time
/// File Name: LetterAtATime.java
/// Date Finished: 9/2/2015
import java.util.Scanner;
public class LetterAtATime
{
public static void main( String[] args )
{
// if string variable is "Box", then length is 2, the x being in the position of 2.
// i <= will go beyond the length of the word
Scanner kb = new Scanner(System.in);
System.out.print("What is your message? ");
String message = kb.nextLine();
System.out.println("\nYour message is " + message.length() + " characters long.");
System.out.println("The first character is at position 0 and is '" + message.charAt(0) + "'.");
int lastpos = message.length() - 1;
System.out.println("The last character is at position " + lastpos + " and is '" + message.charAt(lastpos) + "'.");
System.out.println("\nHere are all the characters, one at a time:\n");
for ( int i=0; i
Picture of the output