Difference between revisions of "Secret Code"

From CompSciWiki
Jump to: navigation, search
Line 1: Line 1:
 
== Secret Code ==
 
== Secret Code ==
  
 +
{{1010PrAD|ProblemName=Secret Code
 +
 +
|Problem= Secret Code
  
 
The following string of text has a secret code encrypted inside it:
 
The following string of text has a secret code encrypted inside it:
Line 19: Line 22:
 
- one called "message" to store the above string to be deciphered
 
- one called "message" to store the above string to be deciphered
 
- one called "result1" to store the result after Step 1
 
- one called "result1" to store the result after Step 1
- one called "secretCode" to store the results after Step 2 and 3
+
- one called "secretCode" to store the results after Steps 2 and 3
  
 
2) The length(), charAt(), toUpper(), and toLower() methods
 
2) The length(), charAt(), toUpper(), and toLower() methods
Line 26: Line 29:
  
 
4) The mod operator
 
4) The mod operator
 +
 +
 +
|SideSection=
 +
[[Image:OperatingSystemExample.jpg|float|267px]]
 +
<BR>
 +
Taken from http://www.flickr.com/photos/daniello/565304023/
 +
 +
An image or By Students section
 +
 +
|Solution=The solution...
 +
 +
}}

Revision as of 12:37, 1 April 2010

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...

Code

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

Back to the Program-A-Day homepage