Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP WITH THIS ASAP. I HAVE TO HAVE COMPLETED WITHIN A HOUR. ANY HELP IS

ID: 3695513 • Letter: P

Question

PLEASE HELP WITH THIS ASAP. I HAVE TO HAVE COMPLETED WITHIN A HOUR. ANY HELP IS GREATLY APPRECIATED. PLEASE PROVIDE ENTIRE SOURCE CODE WITH VARIABLES SPECIFIC TO THIS QUESTION.

A Caesar cipher is a simple encryption where a message is encoded by shifting each letter by a given amount. e.g. with a shift of 3, A -> D, H -> K, X -> A, and Z -> C

Write a program that reads a message from the user and performs a Caesar cipher on its letters with a shift of 1 (shift only letters , leave other characters alone):
For instance:
When user inputs a message: i love odu
Since the shift is 1, the output(encoded message) should be: j mpwf pev

Explanation / Answer

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class Test{ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter message:"); String msg = br.readLine().toUpperCase(); StringBuffer buffer = new StringBuffer(); for(char c : msg.toCharArray()){ if(c=='Z') buffer.append("A"); else if(c == ' ') buffer.append(" "); else buffer.append((char)((int)c+1)); } System.out.println("Encrypted message: "+buffer.toString().toLowerCase()); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote