Write a class polybius, that encrypts and decripts strings

Assignment Help Basic Computer Science
Reference no: EM131317300

Question 1

Polybius was an ancient Greek writer who first proposed a method of substituting different two-digit numbers for each letter. The alphabet is written inside a 5-by-5 square matrix which has numbered rows and columns:


1

2

3

4

5

1

A

B

C

D

E

2

F

G

H

I

J

3

K

L

M

N

O

4

P

Q

R

S

T

5

U

V

W

X

Y/Z

Note that Y and Z are written in the last cell to divide the letters evenly. The context of the message should make clear which of the two letters is intended.

To encode, substitute for each letter the numbers marking the row and column in which the letter appears. Always put the row number first. For example, the number J is 25. The number for J is 25.

The word WATERMELON would be encode as:

53114515433315323534

To decode, simply locate each letter indicate by the number. The number, 53, tells you to find the letter at the intersection of the fifth row and the third column.

Write two function encode and decode. Encode accepts a string of upper case letters and returns a string of digits. Decode accepts a string of digits and returns a string of upper case letters.

Write a function alphaSqueeze that accepts an arbitrary string and returns a string of upper case letters. alphaSqueeze, Write a function digitSqueeze that accepts an arbitrary string and returns a string of digits.

e.g. alphaSqueeze("Ralph124c41") returns "RALPHC" and digitSqueeze("Ralph124c41") returns "12441"

Write a program to thoroughly test the functions.

Question 2

Write a class, Polybius, that encrypts and decripts strings using the Polybius checker board. The class members are decode, encode, alphaSqueeze, digitSqueeze, and the 5 x 5 square matrix described in Polybius Checkerboard 1. The decode and encode are the only public members. alphaSqueeze, digitSqueeze and the matrix are private..

Reference no: EM131317300

Questions Cloud

Write a three-page executive summary of current directions : Then write a three-page executive summary of current directions in business rules and their potential impact on systems development and maintenance.
Importance of dividend policy : What exactly is a homemade dividend? Does this concept lessen the importance of dividend policy?
Recruiting program for your company : Take into consideration how you would approach a recruiting program for your company based on the author's ideas on the subject matter. What challenges would you face if your company were a global conglomerate
Change of the company cost of equity : A company currently has no debt and its beta is 1.20. Its tax rate is 35%. The manager wants to change the capital structure. The expected debt is 40% and equity is 60%. If the market risk premium is 7.0%, and the risk-free rate is 6.0%, what is..
Write a class polybius, that encrypts and decripts strings : Write two function encode and decode. Encode accepts a string of upper case letters and returns a string of digits. Decode accepts a string of digits and returns a string of upper case letters.
What factors will contribute to successful variable pay plan : What factors will contribute to a successful variable pay plan?Should performance incentives for teams be equal for all team members or based on individual performance ?
Bond makes no payments for the first six years : Jallouk Corporation has two different bonds currently outstanding. Bond M has a face value of $10,000 and matures in 20 years. The bond makes no payments for the first six years, then pays $1,700 every six months over the subsequent eight years, and ..
What succession planning process will you use : Will you select, train, or both for these KSAs? How will you ensure your selected successor does not leave the firm? What succession planning process will you use
Balloon payment on your house five years : You have to make a balloon payment on your house five years from now of $15,000. If money can earn an average of 6 percent a year for the five-year period, what factor will you use to determine what to deposit now?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What is the result of the following command

Sometimes when writing code, we need to cast a data type to a different data type. For example, you might need to change an int to a double or vice versa.

  Build an excel model that can accept b as input

Build an Excel model that can accept B as input, and then calculate the profit earned. New demand is calculated based on current demand and B.

  What is the running time of your algorithm

A longest path is a directed path from node s to node t with the maximum length. Suggest an O(m) algorithm for determining a longest path in an acyclic network with nonnegative arc lengths. Will your algorithm work if the network contains directed..

  What was the original purpose of rpg

What is an indicator?3.What trends emerged in the 1970s to influence the enhancements included in RPG 1lI?4.Give an example ofa synt"x error and a logic error in your native language (e.g., English)

  Innovation to optimize system power cost

Would you adopt this innovation if metric you were attempting to optimize was system power x cost? Suppose a defect density of 0.4/cm2, an alpha of 4, and a wafer of diameter 30cm.

  Exam to have an average

Theaverage, ormean,Upper TT,of three examgrades,vv,ss,and xx,is given by the following formula.

  Give the average number of byte-order conversions needed

The probability that both endpoints are big-endian is p 2 ; the probability that the two endpoints use different byte orders is 2p(1 - p).

  Facing a potentially unethical action

Identify the three questions that an ethics-based manager should ask when facing a potentially unethical action

  Implementation of security mechanisms

A security designer is planning the implementation of security mechanisms in a RBAC (Role Based Access Control) compliant system. The designer has determined that there are three types of resources in the system including files, printers, and mail..

  Data structures in an oop program

Suppose you created a video project that has two data structures-an array of strings and a ListView control. You used the Sort() method of the array class to put the film names in ascending order. Then the program populated lstNames with the order..

  Competitive strategy and business strategy

1. What is the difference between competitive strategy and business strategy? 2. Describe the strategy of striving to be the industry's overall low cost provider. What does a company have to do to achieve low-cost provider status?

  Write a java code to check the triangle is valid or not

Write a Java code to check the triangle is valid or not, by inspecting it's sides.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd