#K94707. Message Encoding with a Caesar Cipher
Message Encoding with a Caesar Cipher
Message Encoding with a Caesar Cipher
You are given an integer k and a message string. Your task is to encode the message by shifting each alphabetical character by k positions in the alphabet. The shift should be performed in a cyclic manner so that after 'Z' comes 'A' (for uppercase) and after 'z' comes 'a' (for lowercase). Non-alphabetic characters should remain unchanged.
For uppercase letters, the transformation can be expressed as:
\( \text{new} = ((c - 'A' + k) \mod 26) + 'A' \)
For lowercase letters, it is:
\( \text{new} = ((c - 'a' + k) \mod 26) + 'a' \)
Make sure to handle input and output through standard input (stdin) and standard output (stdout).
inputFormat
The input consists of two lines. The first line contains an integer k (the number of positions to shift). The second line contains the message string which may include spaces and punctuation.
outputFormat
Output the encoded message as a single line.
## sample3
Hello, World!
Khoor, Zruog!