Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In ancient Rome, emperor Julius Caesar used a code to its private correspondence. In this code, each letter in the message was replaced by a

In ancient Rome, emperor Julius Caesar used a code to its private correspondence. In this code, each letter in the message was replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 3, D would be replaced by A, E would become B, and so on.
Your task is now to discover the following message, but before doing so, you will have to discover the shift used to cypher it.
This is the message:
mjd
rd knwxy kqt xyju bfsy f ltqi inllnsl btrfs
rtsjd hfxm kqtb fqq gnl kfhji mtsjdx
kwtsynsl ts ymj kqttw lty ymjr i-gtdx wzssnsl
xmtwyd lty gtym gwtpj hfssty xjj bmfy nx htrnsl
bjfw ymjr fuuqj gtyytrx, bjfw ymjr fuuqj gtyytrx mtsjd
itqhj fsi lfggfsf fsi xmj ljy zu ts rd rtsjd
qtznj ymfy x*** lzhhn, kjsin, fsi ymj rtsjd
xjj ymj hfwwtyx ts mjw bwnxy stb xmj unrux gzlx gzssd
zxji yt ifyj pfsdj stb xmj bfsy rj
bmnqj n lty rd oznhj bfssf yfpj rd to
ny fnsy mjw gnwymifd bnym mjw sfrj ts f hfpj
nk n jajw uqfd ktw lwfij f
lty dtz xyzhp ts rd
ts rd jqjafytw
ljy ny zu, ts rd jqjafytw
hmjhp ny tzy
knwxy kqttw, xyzhp ts ymj ltqi inlljw
xjhtsi kqttw, xyzhp ts ymj inrj unjhj
ymnwi kqttw, xyzhp ts ymj mtti wfy
ktzwym kqttw, kwjfp ny n it sty pstb hfzxj
You can use this JAVA file to begin with your work.
import java.util.Scanner;
import java.io.File;
public class Caesar {
public static void main(String[] args) throws Exception {
String filename = "mistery.txt";
Scanner sc = new Scanner(new File(filename));
String content = "";
while (sc.hasNext()) {
content += sc.nextLine() + " ";
}
//PUT YOUR CODE HERE
System.out.println(content);
}
/**
* Function to apply a shift to a letter in the alphabet
* @param letter: The letter to use
* @param offset: The shift to apply. This must be a positive number
*/
public static char convert(char letter, int offset) {
if (offset < 0) {
System.out.println("The offset must be positive");
return letter;
}
else if (letter >= 'a' && letter <= 'z') {
int size = 'z'-'a'+1;
int pos = letter - 'a';
pos = (pos + offset) % size;
return (char)(pos + 'a');
}
return letter;
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago