When your program is correctly run, it will be provided two strings: the encrypted message and a string that is in the deciphered text. If fewer/more arguments are provided, your program is to output an error:
$ java edu.wit.cs.comp1050.PA4a
Please supply correct inputs: : <encrypted string> <substring>
$ java edu.wit.cs.comp1050.PA4a a
Please supply correct inputs: : <encrypted string> <substring>
$ java edu.wit.cs.comp1050.PA4a a b c
Please supply correct inputs: : <encrypted string> <substring>
If the correct arguments are supplied, you are to output any shifts (00-25) that contain the supplied substring:
$ java edu.wit.cs.comp1050.PA4a 'Jvtwbaly zjplujl pz mbu!' is
09: Secfkjuh isyudsu yi vkd!
19: Computer science is fun!
$ java edu.wit.cs.comp1050.PA4a 'Jvtwbaly zjplujl pz mbu!' 'fun!'
19: Computer science is fun!
If no shifts contain the substring, provide an error:
$ java edu.wit.cs.comp1050.PA4a 'Jvtwbaly zjplujl pz mbu!' '?'
No valid shifts found.
To build this program in an object-oriented fashion, you must first implement a Shifter class. This class is constructed with the encrypted string, and then has methods to both shift by an arbitrary amount and find substrings across all shifts.
To implement this class in an efficient manner, you should use a StringBuilder to shift the encrypted string. You might also find it useful to use an ArrayList to accumulate an unknown number of valid shifts. Look to the JavaDoc’s of the String class for methods to search a string for a substring.
Heres the skeleton code for PA4a
package edu.wit.cs.comp1050;
//TODO: document this class
public class PA4a {
/**
* Error if incorrect command-line arguments are supplied
*/
public static final String ERR_USAGE = "Please supply correct inputs: <encrypted string> <substring>";
/**
* Error if shift could not be found
*/
public static final String ERR_NONE = "No valid shifts found.";
/**
* Outputs all shifts of the encrypted string
* that contain the supplied substring
*
* @param args command-line arguments: <encrypted string> <substring>
*/
public static void main(String[] args) {
// replace with your code
}
}
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Your task is to write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1 . Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case
In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2). When your...
Given java code is below, please use it! import java.util.Scanner; public class LA2a { /** * Number of digits in a valid value sequence */ public static final int SEQ_DIGITS = 10; /** * Error for an invalid sequence * (not correct number of characters * or not made only of digits) */ public static final String ERR_SEQ = "Invalid sequence"; /** * Error for...