Computers and Technology

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();
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:30, huntbuck14
Which of the following methods could be considered a “best practice” in terms of informing respondents how their answers to an on-line survey about personal information will be protected? respondents are informed that investigators will try to keep their participation confidential; however, confidentiality cannot be assured. respondents are informed that a research assistant will transfer all the research data to a password-protected computer that is not connected to the internet, via a usb flashdrive. the computer is located in a research team member’s office. the investigator uses the informed consent process to explain her institution’s method for guaranteeing absolute confidentiality of research data. the investigator uses the informed consent process to explain how respondent data will be transmitted from the website to his encrypted database without ever recording respondents’ ip addresses, but explains that on the internet confidentiality cannot be absolutely guaranteed.
Answers: 1
image
Computers and Technology, 22.06.2019 21:30, sunshinekisses
After you clean an engine with hot water spray, it seems to stall; when it doesn't stall, it's idling noisily. technician a says to check for loose bolts on the flex plate near the torque converter. technician b says to wipe down the spark plug wires and the distributor cap. who is correct? a. technician a b. both technicians a and b c. technician b
Answers: 1
image
Computers and Technology, 22.06.2019 21:50, IdkHowToDoMath
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
image
Computers and Technology, 24.06.2019 06:50, emmv565628
What are the things you are considering before uploading photos on social media?
Answers: 1
Do you know the correct answer?
1. Create a Java program. 2. The class name for the program should be 'EncryptTextMethods'.
3...

Questions in other subjects:

Konu
Chemistry, 28.11.2020 07:40
Konu
Mathematics, 28.11.2020 07:40