Skip to editor
File
New File Ctrl+N
New Folder

Save Ctrl+S
Upload File…
Download as ZIP

Delete File

Reset Files…
View
Toggle Sidebar Ctrl+B
Toggle Terminal Ctrl+`

Word Wrap Alt+Z

Exercise Info
Run
Run Code Ctrl+Enter
Save & Run F5

Clear Output
CS173: Intro to Computer Science - Strings Revisited (3 pts)
Explorer
GitHub

Connect to GitHub to push and pull your project files to a repository.

On the page that opens, create a token with repo scope, copy it, then paste it below.

Paste the personal access token you created on GitHub with repo scope.

Click Refresh to load commit history
Exercise Info

Goals

  1. To iterate over String variables and return part-way through the string iteration.

Instructions

Implement the program below that converts a String to "Pig Latin" according to the rules at the bottom of the page.

Rules

We will simplify the rules as follows:

  • If a String starts with a vowel, simply append “yay” to the end of the String.
  • 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 the String. Then, append “ay” to the end of the resulting String.

Hints

Given a String variable (let’s say it’s called str):

  • You can use the str.substring(i) method to return a String containing all characters in str from position i to the end of the String. Don’t forget that String indices are numbered starting from 0.
  • You can use the str.substring(i, j) method to return a String containing all characters in str from position i up to (but not including) position j of the String.
  • You can use the + operator to concatenate two String values (or their substrings, which are also just String values!).

The Ursinus-WebIDE by Chris Tralie (opens in new tab) and Bill Mongan (opens in new tab)

Your browser does not support WebGL. A graphical rendering canvas would appear here.


          
No suggestions. Code quality feedback will appear here.
Not logged in java
Ln 1, Col 1