subject

1. Create a Java program. 2. The class name for the program should be 'EncryptTextMethods'.
3. In the program you should perform the following:
* You will modify the EncryptText program created in a previous assignment (see code below).
* You should move the logic for encrypting text from the main method into a method named encryptString.
* The encryptString method should have a single String argument and return a String value.
1. Create a second method.
2. The name of the method should be decryptString.
3. In the program you should perform the following:
* The method should have a single String argument and return a String value.
* This method should reverse the encryption process by subtracting one from each character in the String argument passed to it.
* The return value should be the result of the decrypting process.
4.The program should read an input String using the Scanner method.
5. The input value should be passed to the encryptString() method and the encrypted string should be passed to the decryptString() method.
6. The program should output the input string, the encrypted string and the decrypted string.
// Existing Code
import java. util. Scanner;
public class EncryptText {
private static String encodeMessage(String message) {
//convert string to character array
char stringChars[] = message. toCharArray();
//for each character
for(int i=0; i< stringChars. length; i++) {
char ch = stringChars[i];
//if character within range of alphabet
if(ch <= 'z' && ch >= 'a') {
//obtain the character value
//add 1 to the integer value
//enter modulus by 26 since z will become a
//once again add the remainder to 'a'
stringChars[i] = (char)('a' + ((int)(ch - 'a') + 1) % 26 );
}
}
//construct the string message
return String. valueOf(stringChars);
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System. in);
System. out. println("Please enter text to encode: ");
String message = keyboard. nextLine();
message = message. toLowerCase();
System. out. println("Encoded: " + encodeMessage(message));
keyboard. close();
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Lisa’s company, abc ltd., lost its biggest client and is now facing a financial crunch. most of her colleagues have resigned, but lisa decides to stay with the company and assist the management in overcoming the financial situation. which quality is lisa demonstrating? a. self-management b. cooperativeness c. responsibility d. loyalty
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
question
Computers and Technology, 24.06.2019 10:20
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
You know the right answer?
1. Create a Java program. 2. The class name for the program should be 'EncryptTextMethods'.
3...
Questions
question
Business, 20.11.2020 20:00
question
Mathematics, 20.11.2020 20:00
question
Mathematics, 20.11.2020 20:00
Questions on the website: 13722362