Question: Task Write a Java program that will encode plain text into cipher text and decode cipher text into plain text. Create a project and class

Task
Write a Java program that will encode plain text into cipher text and decode cipher text into plain text.
Create a project and class named HW7FirstnameLastname in NetBeans using your actual first and last names to hold your program.
Create following methods and add them to your class:
a method named encode(String p, int key) that takes a plain text p and encodes it to a cipher text by adding the key value to each alphabet character of plain text p using the ASCII chart. The method should return the encoded String.
For example, if p = "attack at dawn" and key is 5, it should be encrypted as "fyyfhpefyeifas" because
a+5=f,t+5=y,c+5=h,k+5=p,+5=e,d+5=i,w+5=a, and n+5=s.
You may only use length() and charAt() String methods in the encode and decode methods in this assignment. No string builder.
a method named decode(String c, int key) that takes a cipher text c and decodes it to a plain text by subtracting the key value from each alphabet character of c. The method should return the encoded String.
Assume that the only characters allowed in Strings p and c are lower-case alphabet letters and spaces. You dont have to validate input for correct characters, but you should make sure you only pass Strings with all lowercase letters for p and c to your methods.
Provide the following menu using a do..while loop in the main method to the user. Options 1 and 2 in the menu should print the returned encoded or decoded text for the user.
Convert plain text to encoded cipher text
Convert cipher text to decoded plain text
Exit
Additional Assignment Requirements
You MUST use For loops in each method in this assignment. Nested loops are not needed.
You may NOT use Java libraries or programming concepts not yet learned in this course. This assignment is designed to assess that you understand the concepts being presented in the course this week, not concepts we will learn at a later time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!