Secret Code

From CompSciWiki
Revision as of 12:27, 1 April 2010 by DavidG (Talk | contribs)

Jump to: navigation, search

Secret Code

The following string of text has a secret code encrypted inside it:

xmydartlkarrsgeoptwwjvbodeblxgbleivetoihewt

In order to decipher it, you will need to:

1) Extract every fourth letter of the string

2) Reverse the order of the extracted letters

3) Set the case of the extracted letters so that they alternate between uppercase and lowercase, with the first letter being uppercase.

To solve this problem:

1) You will need three string variables: - one called "message" to store the above string to be deciphered - one called "result1" to store the result after Step 1 - one called "secretCode" to store the results after Step 2 and 3

2) The length(), charAt(), toUpper(), and toLower() methods

3) String concatenation

4) The mod operator