X481: Review - Loop Practice

Mars' new colony needs your help. This morning, a flurry of distress signals reached Earth, each encrypted with a secret message. Thankfully, we were able to decrypt most of the messages, but now we're left with files hundreds of lines long! We know that each letter of the encrypted message is prefixed with the symbol: %. Help!

Write a method that finds the letter immediately following the symbol '%' by looping through the provided segment of text message. For exaample, "t%Hku%Et%Ye" decrypts to "HEY".

Note: The use of StringBuilder is recommended but not required. Return "Empty Message" if message is empty or no message is present.

Examples:

findMessage("%H%E%L%L%O% %W%O%R%L%D") -> "HELLO WORLD"
findMessage("%NERHDJNH^S%AE$BTH^*&@#%S435thH43f%Acd4") -> "NASA"
findMessage("5r%St-90453mg43-4r5%O09g954mg--53 mgo%Skrio") -> "SOS"

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.