Question: ***** don't use handwriting *************** Q1: Describe the code ? Q2: What are the difficulties that we may face when writing these codes? import java.util.*;
***** don't use handwriting ***************
Q1: Describe the code ? Q2: What are the difficulties that we may face when writing these codes?
import java.util.*;
//Class that Applies Caesar Technique class Caesarr { //Instance variables private String plainText; private int key; //Default Constructor public Caesarr() { //Initializing variables to default values plainText = ""; key=0; } //Overloaded Constructor public Caesarr(String txt, int k) { //Initializing variables to default values plainText = txt; key = k; } //Method that encrypts the text public void encrypt() { int move; //Converting to upper case String str = plainText.toUpperCase(); System.out.print(" Encrypted Text: "); //Iterating over each character for(int i=0; i
//Driver class class CaesarCipherDemo { //Main method public static void main(String[] args) { //Scanner object Scanner reader = new Scanner(System.in); //Reading Plain text from user System.out.print(" Enter Plain Text: "); String plainText = reader.nextLine(); System.out.print(" Enter Key: "); int key = reader.nextInt(); //Creating Caesar Cipher object Caesarr obj = new Caesarr(plainText, key); //Calling method obj.encrypt(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
