• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 5 pages
Other

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

Document preview thumbnail
Preview 2 out of 5 pages

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).

Content preview

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

Connected book
 image
Barry Wittman, Aditya Mathur, Tim Korb Start Concurrent
Publisher: 2013 ISBN: 9781626710092 Edition: Unknown

Document information

Uploaded on
November 7, 2026
Number of pages
5
Written in
2026/2027
Type
Other
Person
Unknown
$6.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
7
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions