Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROGRAM Caesar Cipher Instructions You are going to write a program that allows the user to provide a text over one or more input

JAVA PROGRAM

Caesar Cipher

Instructions

You are going to write a program that allows the user to provide a text over one or more input lines, and encrypts that text based on a Caesar cipher. (Links to an external site.)You can read more about what a Caesar cipher is in the wikipedia page linked---ask questions if you have them. There are two sample outputs below.

Choosing a Key (amount to shift by)

You should give the user a choice at the beginning of your program: do they want to provide a key or have you generate it? If the user provides a key, you can assume they provide a number greater than or equal to 0, in integer format. If you need to generate a key, you should randomly generate a number between 0 and 25, and use that number. We will always assume that the key is added to the character value.

Getting (More) Input

You will print starting info and prompts (like in the sample output), and get enough information to read or generate the key. Then, start prompting for input. This input can be upper or lower case, but it will be all alphabetical letters (A-Z or a-z) and will include no punctuation. If adding the shift number to the input results in a non-alphabetical answer, you should wrap the letter ( z+2 ==> b)

Once you start prompting for input from the user, you should continue prompting, reading, encrypting, and storing statistics, until the user types your name. Once that name is detected, you should stop (it's okay to encrypt your name), and start wrapping things up by printing the end information.

End information

You will notice at the end of the output that you are to display various statistics:

  • the total number of lines read from console
  • the total number of words encrypted
  • the average number of words per line

In addition, you will need to show the full encrypted text, printed after all input has been received. You may choose whether or not to preserve all whitespace, but words must be separated by at least one space, and all letters should be in upper case.

Methods

At a minimum, your program should have the following static methods in addition to method main:

  • a method that encrypts a single word by the appropriate key
  • a method that prompts for input and encrypts all words on that input
  • a method to display overall statistics to the user
  • a method to get the key

You may define more methods than this if you find it helpful, although you will find that the limitation that methods can return only one value will tend to limit how much you can decompose this problem.

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago