One wonderfully interesting thing to do with programming is to write code that w
ID: 3649073 • Letter: O
Question
One wonderfully interesting thing to do with programming is to write code that will encrypt and decrypt messages. A Caesar Cipher was (reportedly) first used by Julius Caesar in sending military messages to Gaul. It's hard to say whether the cipher was successful at protecting messages... or if all of Caesar's enemies in Gaul just couldn't read Latin.Write a program called Caesar.java that will decode a message that has been "shifted" (or moved over) by three characters. One nice trick is because a char in Java is actually represented as a number, and there are more characters available than just those in the alphabet, we don't have to worry about wrapping around from C back to Z, etc. Also because we don't know loops (yet :-) ), you can assume that the message is a precise length, as seen below. Write code that will decipher this phrase that was, in fact, an actual message of Caesar's in 49 BC (well, as best as we know, at least). And remember - it's in Latin...
please use only if and if -else statements . no FOR or WHILE please. i am a beginner and have not gone over that yet. thanks only a code in JAVA JAVA only.
INPUT: A fixed-length set of 12 characters as a String, such as DOHDLDFWDHVW
OUTPUT: "The decoded phrase is: " + result
This is how the prompt screen should look like
Caesar.java:
Please give me the ciphertext: DZHVRPHFRGHV
The decoded phrase is: AWESOMECODES
Explanation / Answer
Here is what you need. I have spent a lot of time in writing this, so please rate :) #include void caesar (char cipher[], int shift); int main () { char cipher[50]; int shift; printf("Enter text to be encrypted IN CAPITAL LETTERS ONLY: "); scanf("%s", cipher); printf("How many shifts do you prefer? 1-10 only: "); scanf("%d", &shift); caesar (cipher, shift); return 0; } void caesar (char cipher[], int shift) { int i = 0; while (cipher[i] != '') { if ((cipher[i] += shift) >= 65 && (cipher[i] += shift)Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.