Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Question
Book Icon
Chapter 3, Problem 40P
Program Plan Intro

Substitution Cipher

Program plan:

  • Import the required java packages.
  • Create the class SubstitutionCipher.
    • Create object “pac” for the class SubstitutionCipher1.
    • Declare the constructor.
    • Create the nested class SubstitutionCipher1.
      • Declare and initialize the string.
      • Declare one character array.
      • Declare the constructor.
    • Define the method encoding() to encode the given string.
    • Define the main() method,
      • Create the object for SubstitutionCipher class.
      • Gets the input string from the user using the scanner.
      • Pass the values for parameters using the object and call the constructor to perform the defined function.

Blurred answer
Students have asked these similar questions
Implement the Plates class buildMap function so that it populates the HashMap with the state abbreviations as keys and the counts of how many each appear in the file as values. Sometimes, the parking attendant will add special notation to help her remember something about a specific entry. There are just non alphabetic characters that she adds to the state - your program should ignore these characters so that an entry like NY* still counts toward the NY plate count. She is also very inconsistent with how she enters the plates. Sometimes she uses upper case, sometimes lowercase, and sometimes she even uses a mix. Be sure to account for this in your program.  Only add information for plates in New England (Maine, New Hampshire, Vermont, Massachusetts, Rhode Island, and Connecticut). Plates.java import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set;   public class Plates {     private Map<String, Integer> plateMap;…
The String class implements Comparable, which means that two strings can be compared to each other. However, the default implementation orders strings based on the ASCII values of their characters, which means that strings that begin with an uppercase letter are always ordered before strings that begin with a lowercase letter. This means that the string “Zoo” would be ordered before the string “aardvark”. Write a Comparator that compares two strings alphabetically so that “aardvark” is ordered before “Zoo”. Hint: convert both strings to upper or lowercase before comparing them.
Write a Java class that would match a string. The class has method  match with String as a return type.  It accepts two inputs: the phrase/sentence string (text) and the pattern string (word). This method finds the first (or all) instances of the pattern in the text and changes that word in all uppercase and return the new phrase. Method countOccurence accepts a phrase/sentence and a pattern string and returns its number of occurrences. Add a main method that will allow the user to input the phrase/sentence and pattern. Call method match and countOccurence. See test case below.  Sample Input:  Text string: You will always have my love, my love, for the love I love is as lovely as love itself.  Pattern string: love  Output:  New text: You will always have my LOVE, my LOVE, for the LOVE I LOVE is as lovely as LOVE itself.  Number of occurrence: 5 For example: Input Result You will always have my love, my love, for the love I love is as lovely as love itself. love New text: You…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education