CS110 Java Programming Assignment #8

Instructor: Trish Cornez


String Manipulation




PROGRAM 1


Write an interactive program that prompts the user to input a string of words.

Translate the given sentence to Pig Latin and display it.

NOTE: Use methodsto make your code as efficient and as organized as possible.
Correctness is the most important element, however, points will be given for the quality of your code.

The Pig Latin system works as follows:

Incorporate the following features :

For example:

Input:        These awful french fries are getting cold

Output:        Hesetay awfulway renchfay riesfay areway ettinggay oldcay


PROGRAM 2



Write a Java program that tests the method doubleIt().
doubleIt() receives a string of characters and returns a string where for every character in the original, there are two characters.
Perform the following tests:

PROGRAM 3



A sandwich is two pieces of toast with something in between. Write a Java program that tests the method getMiddle(). This method should receive a string of text and return the string that is between the first and last appearance of "toast" in the given string, or return the empty string "" if there are not two pieces of toast.
Perform the following tests:




Extra Credit


Create the game of Tic Tac Toe
Construct your game to allow the user to play against the computer.
It will require the use of single and two dimensional arrays, as well as a large, yet manageable, set of logic
combinations to explore.

The algorithm for Tic tacTtoe is often written with game
tree data structures, a topic not discussed in CS110.
To solve this problem without the use of game trees, you
will need to explore and implement all possible game scenarios.

The image below shows an execution of the game with the user,
player X, losing to his opponent, the computer O.