Difference between revisions of "Secret Code"

From CompSciWiki
Jump to: navigation, search
Line 14: Line 14:
 
3) Set the case of the extracted letters so that they alternate between uppercase and lowercase, with the first letter being uppercase.
 
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:
+
The solution will require the following elements:
  
 
1) You will need three string variables:
 
1) You will need three string variables:

Revision as of 12:29, 1 April 2010

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.

The solution will require the following elements:

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