vowels = ['a', 'e', 'i', 'o', 'u']
consonants = ('a'..'z').to_a - vowels
puts "Please enter your name."
name = gets.chomp.downcase
firstLetter = name[0,1]
secondLetter = name[1,1]
without_firstletter = name[1..-1]
without_secondletter = name[2..-1]
if vowels.include?(name[0,1])
puts "Your name in Piglatin is " + name.capitalize + "ray. Carry on."
elsif consonants.include?(name[0,1]) && consonants.include?(name[1,1])
puts "Your name in Piglatin is " + without_secondletter.capitalize + firstLetter + secondLetter + "ay. Congratulations."
else consonants.include?(name[0,1])
puts "Your name in Piglatin is " + without_firstletter.capitalize + firstLetter + "ay. Congratulations."
end
# jennie louie's
def piglatin
puts "your word?"
word = gets.chomp
split_word = word.split(''); #split word into array of letters
vowels = ["a", "e", "i", "o", "u"]
loop=true
while loop
first_letter = split_word[0]
if vowels.include?(first_letter)
loop=false
else # if not a vowel
letter_to_move = split_word.shift
split_word.push(letter_to_move)
loop=true
end #if
end #while
new_word = split_word.push("ay").join
puts "The word " + word + " in pig latin is " + new_word
end
piglatin()