Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IS270: Python Programming LetterCode Program Your neighbor has just excitedly told you that she has discovered this really neat code which she and her friends

IS270: Python Programming

LetterCode Program

Your neighbor has just excitedly told you that she has discovered this really neat code which she and her friends are using to send messages to each other. The code, she explains, involves writing a number in place of each letter of the alphabet. The coding equivalences are:

A=1, B=2, C=3, D=4, E=5, Z=26 (your neighbor doesnt worry about lower case letters).

Furthermore, they are using zero for each space between words. Your neighbor, however, says that it takes a really long time to translate her messages into code or to decode the messages she receives from friends, so she is wondering if you could write a computer program to do those jobs for her (and you have agreed!).

Thus, if your program is Encoding it accepts a simple character message (letters and spaces only) and produces a list of numbers that code the messages according to the scheme described above. At this time you are only operating with uppercase characters and the space no lowercase or other special characters, but to simplify the input you will allow lowercase letters (and encode them according to their upper case version). If during encoding you find a character you are not expecting, use the number 99 in the output stream to represent it. Separate the resulting numbers with spaces for readability.

Conversely, if decoding you will accept a series of integer values from the operator and produce the words (letters and spaces) equivalent represented by those numbers. If any unexpected numbers appear in the list (numbers outside the range 0 to 26) you should print a ? (question mark) in that position of the decoded message.

Note that brute-force type methods for performing these operations - such as checking for each letter separately from A to Z must be avoided. The approach used in the lecture will be based on the ASCII code values for capital letters (A=65, B=66, etc..)

A sample run might be:

=============================================================================

Welcome to the LetterCode program

Choice? (1=Encode, 2=Decode, 0=Quit): 1

Enter your message to encode: I AM PAUL

Your encoded message is: 9 0 1 13 0 16 1 21 12

Choice? (1=Encode, 2=Decode, 0=Quit): 1

Enter your message to encode: HELLO

Your encoded message is: 8 5 12 12 15

Choice? (1=Encode, 2=Decode, 0=Quit): 1

Enter your message to encode: hello world!

Your encoded message is: 8 5 12 12 15 0 23 15 18 12 4 99

Choice? (1=Encode, 2=Decode, 0=Quit): 1

Enter your message to encode: I'M Paul

Your encoded message is: 9 99 13 0 16 1 21 12

Choice? (1=Encode, 2=Decode, 0=Quit): 2

Enter your numbers to decode (separate with commas):1,2,3,0,4,5,6

Your decoded message is:

ABC DEF

Choice? (1=Encode, 2=Decode, 0=Quit): 2

Enter your numbers to decode (separate with commas):1,2 3,4

Your decoded message is:

A?D

Choice? (1=Encode, 2=Decode, 0=Quit): 2

Enter your numbers to decode (separate with commas):24, 25,26 ,27

Your decoded message is:

XYZ?

Choice? (1=Encode, 2=Decode, 0=Quit): 0

Thanks for using the LetterCode program!

==========================================================================

Further, you are to develop this program using a separate python file which contains a class that has static methods to perform the actual encoding and decoding operations (see recorded lecture). This is the beginning of an Object Oriented style of program development.

The program with the main method should be called LetterCode.py The program with the class for performing the operations should be called LetterCodeLogic.py, and the class itself should be called LCL. The LCL class should have two static methods: Encode and Decode (both of which receive a string parameter).

Part A: The part A program will be the Decode function

Part B: The Part B program will be the Encode function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

Why are most training programs not evaluated?

Answered: 1 week ago