summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing4801.java
blob: 37e5781d0f8523abc403ae3e444fc232c87ab856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Listing4801.java */

public class Listing4801
{
  public static void main(String[] args)
  {
    int key = Integer.parseInt(args[0]);
    String msg = args[1];
    for (int i = 0; i < msg.length(); ++i) {
      int c = (msg.charAt(i) - 'A' + key) % 26 + 'A';
      System.out.print((char)c);
    }
  }
}