Assignemnt #86 and Letter At A Time

Code

/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Letter at a Time
/// File Name: LetterataTime.java
/// Date Finished: 1/28/2016

import java.util.Scanner;

public class LetterAtATime
{
	public static void main( String[] args )
	{
		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 < message.length(); i++ )
		{
			System.out.println("\t" + i + " - '" + message.charAt(i) + "'");
		}

		int a_count = 0;

		for ( int i=0; i < message.length(); i++ )
		{
			char letter = message.charAt(i);
			if ( letter == 'a' || letter == 'A' || letter == 'e' || letter == 'E' || letter == 'i' || letter == 'I' || letter == 'o' || letter == 'O' || letter == 'u' || letter == 'U' )
			{
				a_count++;
			}
		}

		System.out.println("\nYour message contains a vowel " + a_count + " times. Isn't that interesting?");
    ///if you chaange the for loop tobe while i <= string length the last thing does not have a character associated with it so there is a problem displayed in powershell
    ///the length(box) is 2, and x would be in the 2nd position
    ///because the length count starts at zero instead of 1 so if its 13 characters long it needs to stop at position 12
	}
}

    

Picture of the output

Assignment 8