Assignment 7B: Caesar Cipher. One of the simplest methods to encrypt a message is to "shift" the letters by a literal value. For example, if we take the letter 'A' and shift it by 2, we get 'C'. This "substitution cipher" gets its name from the Roman emperor Julius Caesar, who was one of the first person known to encode secret messages this way. For this assignment, you will create a program that prompts the user for a message to encode, as well as an offset to encrypt it with. You will then create and use the following methods:

Question

Solving this problem in the Java language

Assignment 7B: Caesar Cipher. One of the simplest methods to encrypt a message is to
"shift" the letters by a literal value. For example, if we take the letter 'A' and shift it by 2, we get
'C'. This "substitution cipher" gets its name from the Roman emperor Julius Caesar, who was
one of the first person known to encode secret messages this way.
For this assignment, you will create a program that prompts the user for a message to encode,
as well as an offset to encrypt it with. You will then create and use the following methods:
A validation method that takes in the message (as a string) and the offset integer
entered by the user. The method should return "true" if the offset is between 0
and 26 inclusively and the message contains only letters and spaces. If it fails
either criteria, it should return “false".
If the validation method returns true, a second encryption method should be
called. This method also takes in the message (as a string) and the offset integer
entered by the user. It should convert the message to UPPERCASE, encrypt
every letter in the message, and leave the spaces as they were. It should then
return the encrypted message.
Hint: The computer treats chars like integers in many ways, meaning you can add and
subtract numbers from them. A string is really an array of chars, and there are methods
in each language to get chars out of the string.
Hint: What happens if our offset makes the letter go past 'Z'? There are several ways to
deal with this – we can either use the modulus operator creatively, or use a loop to add
the offset value one at a time. In the latter case, if the letter becomes greater than 'Z'
(note the single quotes), we can reset it back to 'A' and keep going.
Sample Output:
Enter your message:
KSU class of 2025!
Enter the offset value: 14
Sorry, we can only process messages with letters and spaces, and the offset
must be between 0 and 26.
Do you want to encrypt another message?: Y
Enter your message:
First Year Experience at KSU
Enter the offset value: 13
Your secret message is...
SVEFG LRNE RKCREVRAPR NG XFH
Do you want to encrypt another message?: n
Closing out...
8.50 x 11.00 in
Expand
Transcribed Image Text

Assignment 7B: Caesar Cipher. One of the simplest methods to encrypt a message is to "shift" the letters by a literal value. For example, if we take the letter 'A' and shift it by 2, we get 'C'. This "substitution cipher" gets its name from the Roman emperor Julius Caesar, who was one of the first person known to encode secret messages this way. For this assignment, you will create a program that prompts the user for a message to encode, as well as an offset to encrypt it with. You will then create and use the following methods: A validation method that takes in the message (as a string) and the offset integer entered by the user. The method should return "true" if the offset is between 0 and 26 inclusively and the message contains only letters and spaces. If it fails either criteria, it should return “false". If the validation method returns true, a second encryption method should be called. This method also takes in the message (as a string) and the offset integer entered by the user. It should convert the message to UPPERCASE, encrypt every letter in the message, and leave the spaces as they were. It should then return the encrypted message. Hint: The computer treats chars like integers in many ways, meaning you can add and subtract numbers from them. A string is really an array of chars, and there are methods in each language to get chars out of the string. Hint: What happens if our offset makes the letter go past 'Z'? There are several ways to deal with this – we can either use the modulus operator creatively, or use a loop to add the offset value one at a time. In the latter case, if the letter becomes greater than 'Z' (note the single quotes), we can reset it back to 'A' and keep going. Sample Output: Enter your message: KSU class of 2025! Enter the offset value: 14 Sorry, we can only process messages with letters and spaces, and the offset must be between 0 and 26. Do you want to encrypt another message?: Y Enter your message: First Year Experience at KSU Enter the offset value: 13 Your secret message is... SVEFG LRNE RKCREVRAPR NG XFH Do you want to encrypt another message?: n Closing out... 8.50 x 11.00 in

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Abby, a single taxpayer, purchased 10,000 shares of § 1244 stock several years ago at acost of $20 p...

A: Click to see the answer

Q: An element has an atomic number of 16. An ion of this element has a 2-charge. How was the ion formed...

A: Click to see the answer

Q: A yo-yo-shaped device mounted on a horizontal frictionless axis is used to lift a 37 kg box as shown...

A: Given information: Here, m and a are the mass and the acceleration of the block respectively, and r...

Q: The equation y = kx represents a proportional relationship between x and y, where k is the constant ...

A: Click to see the answer

Q: Bank reconciliation and entries  The cash account for collegiate Sports Co. on November 1, 20Y9, ind...

A: The bank reconciliation statement is prepared to adjust the balances of cash book and pass book to m...

Q: What are some advantages of Walmart purchasing established web businesses?

A: Walmart is the world's largest leading ecommerce and offline platform last year in pandemic Walmart ...

Q: Suppose that a market is described by the following supply and demand equations: QS= 2P QD= 300 - P ...

A: Since you have posted questions with multiple sub-parts, we are answering the first three parts for ...

Q: Welcome to the CSE142 Encryption Machine The program lets you encrypt a message with a key for your ...

A: Solution:--   1)Given in the question is to encrypt a given message for our receipent to      decryp...

Q: The standard definition of a quart is equal to 947 mL. Calculate the percent error of a student's m...

A: Given  Actual value of quart=947 mL The measured value of quart=938 mL Percent error has to be calcu...

Q: England and Ireland have warmer weather than you would predict based on their latitude. What causes ...

A: Earth as a sphere is surrounded by numerous hypothetical lines called latitudes and longitudes, and ...

Q: Finding the Volumes of Composite Figures Answer the following questions. 1. The solid figure shown b...

A: The composite figure consists of two blocks 1) Yellow block of length = 2inches                     ...

Q: A 1.000 g sample of an unknown compound containing only carbon, hydrogen, and oxygen was analyzed th...

A: We have to predict the empirical formula of compound.

Q: Which of the following statements is(are) true? a. A spoonful of sugar is a mixture.b. Only elements...

A: The statements, which are all true has to be given.

Q: Consider an iron bar on a balance as shown   As the iron bar rusts, which of the following is true? ...

A: Rusting of iron is a chemical process in which iron combines with oxygen from the air to form iron o...

Q: Gumbo company had the following transactions during the month of December. What was the December 1 c...

A: Cash -Cash is legal tender currency that may be used to exchange products, debt, or services. typica...

Q: A student gave a molecule the following incorrect name: 2-ethyl-3-methyl-5- propylhexane. What is th...

A: Incorect name: 2-ethyl-3-methyl-5-propylhexane. Correct IUPAC name of the molecule =?

Q: 2. A passenger bus leaves a bus station at 9:30 am and travels 3 hours on a Northbound road. A secon...

A: Click to see the answer

Q: Database A contains 40 data items and is made up with an equal number of the values of 0 and 100 and...

A: Click to see the answer

Q: Amazon is thinking of generating its own power supply for its datacenters and hence a power grid nee...

A: Given:

Q: Draw the unit circle and plot the point P=(6,2). Observe there are TWO lines tangent to the circle p...

A: Click to see the answer

Q: This program will store roster and rating information for a soccer team. Coaches rate players during...

A: Here I implemented python program for your given problem. here i used dictionaries for stored data v...

Q: Static holding is when you hold the same posture for a long period of time  True or false

A: Static: The fixed or stationary characteristic of any object or body is known as static.

Q: Static budgets are often used:A.By production departmentsB.By administrative departmentsC.By respons...

A: Static budgets are those budgets or estimates in which future forecast is made about anticipated inp...

Q: A bar of mass m rests perpendicularly on a pair of rails separated by a distance L that lie in the x...

A: Given, B=cl(a+x)

Q: 1.23 LAB: Warm up: Variables, input, and type conversion (1) Prompt the user to input an integer bet...

A: Source Code: #take int,float,character and string input from user   user_int=int(input('Enter intege...

Q: Freon- 12 (CCI2F2) is used as a refrigerant in air conditioners and as a propellant in aerosol cans....

A: Click to see the answer

Q: Financial Option 3: $30 Million Investment in Bonds Rationale for investment: The business that’s of...

A: As we contemplating investing in the bonds of this company, we are actually finding the NPV. NPV is ...

Q: When 3.02 g of NH4Cl  is dissolved in enough water to make 20.05 mL of solution, the temperature dro...

A: To find enthalpy change, first find q of reaction by using formula of q. Then divide the calculated ...

Q: The graph of two functions, f and g, is illustrated below. Use the graph to answer parts (a) through...

A: Two functions can be added, subtracted, multiplied or divide together. Consider two functions fx and...

Q: What Did Mrs. Margarine Think About Her Sister's Husband? For each exercise, select the correct rati...

A: Click to see the answer

Q: driver in a moving car applies the brakes. The car slows to a final speed of 1.70 m/s over a distanc...

A: This problem can be solved by using first and third equation of motion which is given as v = u + at ...

Q: Which of the following complete Lewis diagrams represents a molecule containing a bond angle that is...

A: Lewis structure is a method of of representing bonding pattern in a molecule. it represent how diffe...

Q: Why is Newton's cradle (Newton's balls) described as an "almost-ideal" closed system? Explain your r...

A: Newton's cradle or Newton's balls,When one of the balls is lifted and released, it strikes the remai...

Q: Siven directed line segment KM , find the coordinates of L uch that the ratio of KL to KM is 1:3. Pl...

A: Topic:- coordinate geometry  Note:- as per our guideline if more than one question uploaded than the...

Q: 1. A student with a DMAF presents to the medical room with the complaint of vomiting and temperarure...

A: A student with DMAF- Diabetes Medication Administration Form - DMAF- Diabetes Medication Administrat...

Q: The world record for the hundred meter dash is 9.58 s. What is the corresponding average speed in un...

A:  

Q: In the diagram, L is the midpoint of KM. Find the length of KL. A. 13 B. 15 C. 17 D. 19

A: If L is the mid point , Then KL= LM  2x-3= x+7  x = 10    

Q: Neptune Corporation borrowed extensively when interest rates were low. Now the firm wants to decreas...

A: Whenever a corporation requires additional funds to raise capital for supporting its financial needs...

Q: Write a single statement that assigns avg_sales with the average of num_sales1, num_sales2, and num_...

A: Click to see the answer

Q: Mendez Company has identified an investment project with the following cash flows. Year Cash Flow $ ...

A: Present Value is referred to as the current value of cash flows streams or future sum of funds, whic...

Q: use Java. Given main(), define the Product class (in file Product.java) that will manage product inv...

A: Write the Product Class in Product.java File, write the required constructor, getter and setter meth...

Q: Rank the following base pairs according to their stability. Rank from most to least stable. To rank ...

A: The DNA molecule is made up of 2 strands in a helical form. The two strands of DNA are held together...

Q: Journal entries and trial balanceElite Realty acts as an agent in buying, selling, renting, and mana...

A: "Since you have asked multiple sub part question we will solve the first three sub part question for...

Q: Suppose a small economy has two income tax rates: 15% for all income up to $50,000 and 30% for any i...

A: 1. (a) Income of Amy          = $20,000 Tax paid by  Amy       = 15% of 20,000       = (15/100) * 20...

Q: You're trying to isolate limonene, an oil found in grapefruits which can be used to make medications...

A: Thin Layer Chromatography is one of the chromatography technique used to isolate non-volatile mixtur...

Q: The following figure shows the acceleration of objects of different mass that experience the same fo...

A: Click to see the answer

Q: he electron microscope uses the wave property of electrons to observe very small objects. A moving e...

A: Click to see the answer

Q: Drag the labels to the appropriate location in the figure.

A: Epithelial tissue- is one of the four basic types of tissue found in an animal. Epithelial tissue li...

Q: Match each description below with the following microscopic pictures. More than one picture may fit ...

A: Click to see the answer

Q: A student needs to run 3.2 km to get to school. If the student can run 55 mi/hr how many hours will ...

A: Click to see the answer