import java.util.Scanner, public class VigenereEncoding public static void main(
ID: 3889549 • Letter: I
Question
import java.util.Scanner, public class VigenereEncoding public static void main(Stringl) args) Scanner keyboard = new Scanner(System.in); String key-"GUPTA"; System.out.println Please enter a text to encode: ") String message keyboard.nextLine0 String encodedMessage = encodeMessager message, key); Systemout println String:"+message): +decodeMesssage(encodedMessage, key)) private static String decodeMesssage(String encodedMessage, String key) String res encodedMessage = encodedMessage.toUpperCase(); for (int i-0,j-0; iencodedMessage.lengthO; it)t char c encodedMessage.charAt(i) res += (char) ((e-key.charAuj)" 26) % 26 + A.); i-Hj % key. length( ); else t res += c; return res. private static String encodeMessage(String message, String key) String res = ""; message -message.toUpperCase0 for (int i- 0.j- 0;imessage lengthO: i++) char c = message.charAt(i); res +-(char) ((c + key.charAt(j)-2 * .A.) % 26 +-A.); j-Hj % key. length(); else f res c return resExplanation / Answer
In the class, VigenereEncoding, follow the below steps.
=> Replace(delete) the line String key = "GUPTA"; with the below codes.
System.out.print("Enter the key: ");
String key = keyboard.nextLine();
Remaining codes will be as is.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.