Question: import java.util,Scanner; public class Messages { private String message; private int code; Scanner keyboard = new Scanner ( System.in ) ; / / This method
import java.util,Scanner;
public class Messages
private String message;
private int code;
Scanner keyboard new Scanner
System.in;
This method prompts the user to enter a string
public void setMessage
r
System.out, printlnPlease enter a message to encrypt: ;
message keyboard.nextlinel;
end setMessage
This method will print out the contents of the string
public void getMessage
System.out.printlnThe message you entered is as follows: message;
System.out.println;
end getMessage
This method prompts the user to enter the code with which to encrypt the string
public void setCode
SystemoutprintlnPlease enter the code with which to encrypt the message: ;
code keyboard,nextInt;
end setCode
This method show's the user what the value for code is that they gave
public void getCode
System.outprintlnThe code you entered is as follows: code;
System.aut.println;
end getCode
This method converts the character that is passed in to the encrypted version
private char encryptchar letter
l
if letter
else
return letter;
letter charintletter codes
return letter;
end encrypt
This method calls encrypt, passing in one character at a time using as loop
private void encryptall
i
charl messageArray message,tocharArray;
charif cncryptedArray new charmessage length;
for int index ; index message. length; Indext
encryptedArrayfindex magryntl
end encryptall
This method prints out the results of encryptAll
public void printOut
System.out.printlnThe encrypted message is as follows:"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
