• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Otro

Java Vigenère Cipher Lab Solution - Complete Code (Vigenere.java), Trace Table & Beginner Study Guide

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

Get 100% verified solutions and step-by-step explanations for the Vigenère Cipher Java Lab! What's included in this guide: Complete Java Code: Clean, fully commented V file adhering to all project requirements (single loop, 'A' character conversion, custom keyword index). Step-by-Step Study Notes: Logical breakdown of cipher formulas, character shifting logic, and modular arithmetic. Execution Trace Table: Detailed character-by-character trace table for the sample input (ATTACKATDAWN + LEMON = LXFOPVEFRNHR).

Vista previa del contenido

Lab 7: Vigenère Cipher



Due by the end of class
The objective of this lab is to implement the Vigenère Cipher. In the Vigenère
Cipher, we use a special keyword to encrypt a message. We represent each letter
of the alphabet as a number from 0-25. In order, we add each letter from the
keyword to the message and mod by 26. If the keyword is shorter than the
message, we simply repeat the keyword.
For example, let’s say that the message is HOWSTUFFWORKS and the keyword
is CIPHER. The following table shows how we can find the final version of the
ciphertext, borrowed from How Stuff Works.
Plain Text: HOWSTUFFWORKS
Keyword: CIPHER
Cipher Text: JWLZXLHNLVVBU
Your mission is to write a program that will read a message and a keyword
and apply the Vigenère Cipher to it.


Specification
Create a project called Lab7. Add a class called Vigenere.
Your main() method should prompt the user for some plain text. Then, it
should prompt the user for a keyword. You may assume that both the plain
text and the keyword contain no spaces and are only made up of upper-case
letters.
To perform the encryption, you need to loop through the plain text and add
each letter from the keyword to it, mod 26. Unfortunately, neither the letters
in the plain text nor in the keyword have values between 0 and 25. You will
have to convert those letter values so that they are between 0 and 25, then do
the add, then do the mod, then convert them back to the proper ASCII values.
Note: You should never use the numerical value of an ASCII character to do
these conversions. If you wish to add the value of the letter A, add ’A’.
You only need one loop for this program. However, the plain text is generally
longer than the keyword. So, though you will only need one loop, you need to
keep track of where you are in the keyword independently of the plain text.
Whenever you get to the end of the keyword, you should set that index back to
0.


1

, Sample Output
Here is an example of sample output for plain text ATTACKATDAWN and keyword
LEMON. Your output should match as closely as possible.

Enter your plaintext: ATTACKATDAWN
Enter your keyword: LEMON
Your cipher text is: LXFOPVEFRNHR


Turn In
Turn in your code by uploading Vigenere.java from the Lab7/src folder wher-
ever you created your project to Brightspace. Do not upload the entire
project. I only want the Vigenere.java file.
All work must be done individually. Never look at someone else’s code.
Please refer to the course policies if you have any questions about academic
integrity. If you have trouble with the assignment, I am always available for
assistance.




2

Libro relacionado
 image
Barry Wittman, Aditya Mathur, Tim Korb Start Concurrent
Editorial: 2013 ISBN: 9781626710092 Edición: Desconocido

Información del documento

Subido en
7 de noviembre de 2026
Número de páginas
5
Escrito en
2026/2027
Tipo
Otro
Personaje
Desconocido
$6.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
7
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes