logo CodeStepByStep logo


Language/Type: VB file input
Author: Nick Troccoli (on 2020/07/15)

Write a subroutine named PigLatin that accepts as a parameter a string representing an input file name. Your subroutine should, preserving line breaks, print out the input file's text in a simplified version of Pig Latin, a silly English variant where the first letter of each word is moved to the end. The rules for translating a word to Pig Latin are as follows:

  • If the word starts with a vowel (aeiou), simply append "yay". For example, "elephant" becomes "elephantyay".
  • If the word starts with a consonant, move the consonant to the end, and append "ay". For example, "welcome" becomes "elcomeway".

As an overall example, if the input file lincoln.txt contains the following text:

four score and
seven years ago our
fathers brought forth on this continent a new nation

Then the call of PigLatin("lincoln.txt") should produce the following output:

ourfay coresay andyay
evensay earsyay agoyay ouryay
athersfay roughtbay orthfay onyay histay ontinentcay ayay ewnay ationnay
Function: Write a VB function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.