Assignemnt #82 Letter At A Time!
Code
/// Name:JJ Deng
/// Period: 6
/// Program Name: LetterAtATime
/// File Name: LetterAtATime.java
/// Date Finished: 2/13/2016
import java.util.Scanner;
public class LetterAtATime
{
public static void main( String[] args )
{
Scanner msg = new Scanner(System.in);
System.out.print("What is your message? ");
String message = msg.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 v_count = 0;
for ( int i=0; i< message.length(); i++ )
{
v_count++;
}
}
System.out.println("\nYour message contains " + v_count + " vowels. Isn't that interesting?");
}
}
Picture of the output