PigLatin - first = word.charAt(0); first =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Pig Latin ******************/ import java.util.Scanner; public class PigLatin { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); System.out.println("Please type a word to be translated into Pig-Latin."); // Instructions. String word, pig; // Defines the variable word char first; word = stdIn.nextLine(); // Defines 'word' as what is typed in.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: first = word.charAt(0); first = Character.toLowerCase(first); if (first == 'a'|| first == 'i' || first == 'o' || first == 'o' || first == 'u') { pig = word + "h"; } else { pig = word.substring(1) + first; } pig = pig + "ay"; System.out.println(pig); } }...
View Full Document

This note was uploaded on 04/03/2010 for the course COMPSCI 600.107 taught by Professor Houlahan during the Spring '08 term at Johns Hopkins.

Ask a homework question - tutors are online