Secret Code

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

Jump to: navigation, search

Secret Code

Back to the Program-A-Day homepage

Problem

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 Steps 2 and 3

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

3) String concatenation

4) The mod operator

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

The solution... [SolutionCode =


Code

SolutionCode goes here. Please DO NOT put your code in <pre> tags!

Back to the Program-A-Day homepage