COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Text Processing DNA.java EggyPeggy.java



EggyPeggy Program


Description

This program inputs a string and adds the word “egg” in front of every vowel in a string.

Associated Concepts:

StringBuilder

Algorithm:

main method:

Input a string from the keyboard

Call eggIt method and pass the string as the argument

Print the result

Method eggIt definition

Create a StringBuilder object based on the input string

Loop: go through each letter in the StringBuilder object

     Retrieve the letter at index i

     If the letter is a vowel

          Insert "egg" in front of it

Return the result

Source Code