Tuesday, March 10, 2015

Warm up 3

Task: Create a piglatin Translator with the following rules
  1. If the English word begins with a vowel ("a", "e", "i", "o", "u"), add "yay"to the end of the word to produce the Pig Latin translation.

  1.  If the English word begins with a consonant (a non-vowel), move all leading consonants to the end of the word and add "ay" to produce the Pig Latin translation. You should treat the letter `y' as a vowel when it occurs after the first character in a word. You should also treat the letter pair "qu" together as a consonant. Here are some examples.
English
Pig Latin
yes
esyay
example
exampleyay
bygone
ygonebay
test
esttay
quiz
izquay
strip
ipstray
trips
ipstray
schnitzel
itzelschnay
rhyme
ymerhay






This assignment was fairly simple however, some parts proved to be a challege. One problem I faced was I could not use one "for loop" when iterrating through the word or phrase. To solve this problem I created a second array called, "constanant" and used of second "for loop" to iterrate though the word or wo for a non-vowel. Another problem was I was not able to print the translated word onto a single pane, instead it has multiple.

Wednesday, March 4, 2015

Warm Up: 1

Task: Enter user full name and split the full name into the different parts (first and last name).

Method 1: Use .indexOf( ) and .subString( )


This method had more steps however very easy to implement and conceptually understand.





Method 2: Use .split( )

I felt this method was faster and easy to implement in my program

Warm up: 2

Task: Build an age checker to see if the user is 18 years old

Method 1: Using if/else statments

In this particular code I use if/else statements which became complex because I nested many if/else statements. Another problem with this method is that I had to input the date therefore, if I wanted to try this code out tomorrow it would not work because I would have to update the current date (Not Practical).        



 Method 2: Using Switch Statement and Date Class               
Image 1



Method 2 had more coding but overall simplified the complexity of the code. As well as reducing the complexity instead, of having to input the current date I used the Date class to automatically get and input the current date.