JulianJulianov

09.TextProcessingExercise-Caesar Cipher

Apr 19th, 2020
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. 09.Caesar Cipher
  2. Write a program that returns an encrypted version of the same text. Encrypt the text by shifting each character with three positions forward. For example A would be replaced by D, B would become E, and so on. Print the encrypted text.
  3. Examples
  4.  
  5. Input                     Output
  6. Programming is cool!      Surjudpplqj#lv#frro$
  7. One year has 365 days.    Rqh#|hdu#kdv#698#gd|v1
  8.  
  9. using System;
  10.  
  11. public class Program
  12. {
  13.     public static void Main()
  14.     {
  15.         var text = Console.ReadLine();
  16.             var encryptedText = "";
  17.             for (int i = 0; i < text.Length; i++)
  18.             {
  19.                 encryptedText += (char)(text[i] + 3);
  20.             }
  21.             Console.WriteLine(encryptedText);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment