Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language is in java. thank you given files: import java.util.Scanner; public class CipherDemo { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in);

language is in java. thank you
image text in transcribed
given files:
import java.util.Scanner;
public class CipherDemo {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter some text to encrypt");
String input = keyboard.nextLine();
System.out.println("Enter a key");
int key = keyboard.nextInt();
try {
Cipher c = new Cipher(input, key);
System.out.println("Plain text: " + c.getPlainText());
System.out.println("Cipher text: " + c.getCipherText());
System.out.println("Key: " + c.getKey());
} catch (EmptyPlainText e) {
System.out.println(e.getMessage());
} catch (UselessKeyException e) {
System.out.println(e.getMessage());
System.out.println("Useless key: " + e.getUselessKey());
}
}
}
Create a class called Cipher. Make the constructor accept some text and a key. Encrypt the given text using the key. Use the following cipher: Take the key and mod it by 26. Example: a key of 30 becomes 4. . If the character is a letter, shift it by the key, but wrap around the alphabet if necessary . If the character is not a letter, then shift it by the key but do not wrap. Check the test cases for example, Make getters to support the Cipher Demo. Also, make two custom Exceptions called UselessKeyException and EmptyPlain Text. In your constructor, throw Useless KeyException the key is divisible by 26 and throw EmplyPain Text if the plain text is zero characters View required output Test Case 1 Standard Input Files in the same directory abc ENTER 1 ENTER Cipher Demo.java Enter some text to encryptin Enter a keyin Plain text: abc In Cipher text: bcd[in Key: 11n Test Case 2 Standard Input Files in the same directory Cpher Demo java xyz ENTER 1 ENTER Enter some text to encryptin Enter a key in Plain text: xyzn Cipher text: yza in Key: 1in Test Case 3 Standard Input Files in the same directory - Cipremaja ABC ENTER

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago