CS173: Intro to Computer Science - Strings Revisited (3 Points)
Developed by Professor Tralie and Professor Mongan.Exercise Goals
The goals of this exercise are:- To iterate over
String
variables and return part-way through the string iteration.
Welcome to our online modules system!
Be sure to log in with your Urinus ID
before you proceed.
For example, Professor Tralie's ID is ctralie.
If you are not an Ursinus student, that's fine!
Just make something up, and you can still run everything
Rules
We will simplify the rules as follows:
- If a
String
starts with a vowel, simply append “yay” to the end of theString
. - Otherwise, modify the string so that all the letters of the
String
up to (but not including) the first vowel are moved to the end of theString
. Then, append “ay” to the end of the resultingString
.
Hints
Given a String
variable (let’s say it’s called str
):
- You can use the
str.substring(i)
method to return aString
containing all characters instr
from positioni
to the end of theString
. Don’t forget thatString
indices are numbered starting from 0. - You can use the
str.substring(i, j)
method to return aString
containing all characters instr
from positioni
up to (but not including) positionj
of theString
. - You can use the
+
operator to concatenate twoString
values (or their substrings, which are also justString
values!).