COS 100: Introduction to Programming

Interim 2021

HW Project 08: Decryption

Due: 01/22 Fri 10pm

Ktw ymjwj nx stymnsl htajwji ymfy bnqq sty gj wjajfqji, stw mniijs ymfy bnqq sty gj pstbs.
Qzpj 12:2
If you are pair programming, do NOT start coding without your partner. You should read the assignment first, feel free to think about it, but do not actually start coding.

Project goal

Decrypt a message by using frequency analysis.

Prerequisites

Background information

Project specification

Write a program that
  1. Prompts the user for an encrypted message.
  2. Counts how many times each letter of the alphabet occurs in that message.
  3. Prints out the letter counts for the whole alphabet.
  4. Tells the user what the most commonly occurring letter was. (In the event of a tie, go with the letter that appears earliest in the alphabet.)
  5. Decrypts the message by shifting the most frequent letter to the letter 'e'.
  6. Prints out the decrypted message.

Notes and hints

Suggested order of development

This project is substantially more involved than previous projects. Plan before you code! Remember, add one small feature at a time and test to make sure it's working before you move on. Ask the professor or the CS Lab tutors for help when you get stuck. Getting help and feedback early will help you to finish this project on time.

Sample runs

  1. Please enter an encrypted message: The quick brown fox jumps over the lazy dog.
    Letter counts:
    a: 1, b: 1, c: 1, d: 1, e: 3, f: 1, g: 1, h: 2, i: 1, j: 1,
    k: 1, l: 1, m: 1, n: 1, o: 4, p: 1, q: 1, r: 2, s: 1, t: 2,
    u: 2, v: 1, w: 1, x: 1, y: 1, z: 1.
    The most common letter was 'o'.
    A key of 16 will shift 'o' to 'e' and give:
    Jxu gkysa rhemd ven zkcfi eluh jxu bqpo tew.
    
  2. Please enter an encrypted message: Rz'mz xgjnz oj wzdib mzvyt ajm Xjhkpozm Nxdzixz 105!
    Letter counts:
    a: 1, b: 1, c: 0, d: 2, e: 0, f: 0, g: 1, h: 1, i: 2, j: 4,
    k: 1, l: 0, m: 4, n: 2, o: 2, p: 1, q: 0, r: 1, s: 0, t: 1,
    u: 0, v: 1, w: 1, x: 4, y: 1, z: 8.
    The most common letter was 'z'.
    A key of 5 will shift 'z' to 'e' and give:
    We're close to being ready for Computer Science 105!
    

Grading

Start early, have fun, and discuss questions on Moodle.