CSCI 161 — Lab 8

Due: Wednesday, April 4th, 2018 @ 8:00PM

Overview

Write a program that translates an English phrase into a Pig Latin phrase. Input a phrase from the user and translate it to pig latin. You can assume the phrase will be on a single line.

Use at least the REQUIRED METHODS listed below, with the exact same SPELLING for method names and parameters.

Input Specification

The input will be an English phrase, with NO terminal punctuation. Read the phrase as a SINGLE STRING using the nextLine method.

Use PRECISELY the format below with the EXACT same SPACING and SPELLING.

Please enter a phrase ==> <user input>

Output Specification

Output an introductory message, a prompt for the English word, and a translation for the inputted word.

Use PRECISELY the format below with the EXACT same SPACING and SPELLING. The output below assumes the user entered "Humpty Dumpty sat on the wall".

This program will convert an English phrase into Pig Latin.

Please enter a phrase ==> Humpty Dumpty sat on the wall

"Humpty Dumpty sat on the wall"
  in Pig Latin is
"umpty-Hay umpty-Day at-say on-way e-thay all-way"

Required Methods


// Prompt and read a phrase to translate
public static String readPhrase (Scanner console)

// Convert a phrase to Pig Latin and return it
public static String convertPhrase (String englishPhrase)

// Convert a word to Pig Latin and return it
public static String  convertWord (String englishWord)

// Return true if "c" is a vowel, false otherwise.
// Handle both lowercase and uppercase letters.
public static boolean isVowel (char c)

// Print result of translation
public static void printResult (String englishWord, String pigLatinWord)

Hints

You already wrote a method to convert a single word (convertWord). Apply it to each word in the phrase, forming the translated phrase by concatenating the translated words. If you did not get convertWord working on the first lab assignment, you need to get it working now.

Class Scanner can process a String (instead of System.in) consisting of multiple words, and break it into words that are separated by whitespace (tabs, spaces, and newline characters). You know other ways to break a line into words, so you do NOT have to use this technique.

Correctly handle whitespace before and after words.

Style

Use good programming style:

Submission

Please name your program PigLatin.java

Submit the Java source code file on Autolab under the "Lab 9" assignment.

Grading