Answered step by step
Verified Expert Solution
Question
1 Approved Answer
solve in easy way java Download the main file here: CaesarCipherClient.java // do not change the main. do not submit this file main will pass
solve in easy way java
Download the main file here: CaesarCipherClient.java // do not change the main. do not submit this file main will pass the message and the key from the user to the cipher method. The assignment is to write a method named cipher that takes two parameters, message and the key. -.Start your assignment with the following lines in Cipher.java public class Cipher \{ public static void cipher(String message, int key) \{ - Convert all letters to a lowercase - Encode each letter by shifting it the right amount using the key, and display the encoded letters into a console window. - Encode each digit (09) with its ASCII value shifted by the negative value of the key (1>9key,0>48-key), and display the encoded digits into a console window. - Skip all the punctuation marks, blanks, and anything else other than letters and digits and do NOT display them in a console window. - Required file/class name: Cipher.java to save the cipher method Here's the sample output: Your Message? Attack zerg at dawn! Encoding Key? 3 Your message: dwwdfnchujdwgdzq Your Message? 10 go forward Encuding Key? 5 Your message: 44431 tktwbfwi // Do not change this code. /I run this client code with your cipher.java // 1. compile cipher.java // 2. run Caesarcipherclient.java // do not submit.this code on Canvas. Only submit the Cipher.java import java.util. *; // for Scanner public class caesarcipherclient \{ public static void main (String [] args) \{ Scanner console = new Scanner (System. in); System.out.print ("Your Message? "); String message = console. nextLine(); System.out.print ("Encoding Key? "); int key = console:nextint(); // Place your Cipher.j java in the same directory where you saved the main. // you have to use the following names: Cipher.java and cipher for the method. Cipher.cipher (message, key); \} \} The purpose of this assignment is to give you some practice using characters and Strings. A second purpose it to give you additional practice in using the Java API to find the methods you need. I will suggest some methods you might need at the bottom of this page. The idea of a Caesar cipher is this: you encode a message by shifting each letter some number of places. Thus, if the shift is 2 , then A becomes C. B bernmec n Surprisingly, you can do this by simply doing arithmetic with characters, but you do need to reassure Java that the result is a character. If, for example, contains the value then gives the integer result, which you can turn back into a character by saying , giving the value Unfortunately, does not give you the letter (you can see why from the picture above), but if you realize you went past . you can subtract 26 (so the result is or , and this will give you This also means that if you encode a message with a shift of ,you can decode it with another shift of Here's the assignment: 1. Download the main file here: CaesarCipherClient.java .// do not change the main. doStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started