1. Home
  2. Computing & Technology
  3. Java
Paul Leahy
Paul's Java Blog

By Paul Leahy, About.com Guide to Java

Monday's Programming Question

Monday October 6, 2008

Last week the challenge was to make a decoding program. It would seem silly not to make the encoder that goes with it.

Here's the same letter switch code:

Decodedabcdefghijklm
Encodedprjitgcoxbsyn
Decodednopqr stuvwx yz
Encodedwdemh uvlzfq ka
For example, the name "bob" becomes "rdr" (i.e., b=r, o=d, b=r). Don't worry about capital letters, just assume that all of the text is in lowercase.

This week write an encoder along the same principles of the decoder, except I want to highlight the difference between using a normal for loop and a "for each" loop. Your program should take a line of text entered by the user, use a combination of a for each loop and switch statement to encode it, and finally display the encoded line to the user.

The question is can your program encode this line?

it was a dark and stormy night

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Java
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Java

©2010 About.com, a part of The New York Times Company.

All rights reserved.