Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 3, Problem 42P
Program Plan Intro
Random Cipher
Program plan:
- Import the required java packages.
- Create the class StringRandom.
- Declare the required variables.
- Declare the constructor.
- Define the method generteString() to generate the output string for the user entered input string.
- Define the method generate() to generate the output string.
- Define the method ecoding() to encrypt the user entered string.
- Define the method print() to print the output on the console window.
- Define the main() method,
- Create the object for StringRandom class.
- Get the input from the user using the scanner class
- Pass the values for parameters using the object and call the constructor to perform the defined function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
implement a c# program that tests our implementation of the CSet class by creating two sets, performing a union of the two sets, an intersection of the two sets, finding the subset of the two sets, and the difference of the two sets.
Computer Programming Java
Design a class named LinearEquation for a 2x2 system of linear equations:
ax + by = ecx + dy = f
x = (ed - bf)/(ad - bc )
y = (af - ec)/(ad-bc)
The class contains:■ The private data fields a, b, c, d, e, and f with get methods.■ A constructor with the arguments for a, b, c, d, e, and f.■ Six get methods for a, b, c, d, e, and f.■ A method named isSolvable() that returns true if is not 0.■ The methods getX() and getY() that return the solution for the equation.Draw the UML diagram for the class, and then implement the class. Write a test program that prompts the user to enter a, b, c, d, e, and f and displays the result. If is 0, report that “The equation has no solution.”
Chapter 3 Solutions
Data Structures and Algorithms in Java
Ch. 3 - Prob. 1RCh. 3 - Write a Java method that repeatedly selects and...Ch. 3 - Prob. 3RCh. 3 - The TicTacToe class of Code Fragments 3.9 and 3.10...Ch. 3 - Prob. 5RCh. 3 - Prob. 6RCh. 3 - Prob. 7RCh. 3 - Prob. 8RCh. 3 - Prob. 9RCh. 3 - Prob. 10R
Ch. 3 - Prob. 11RCh. 3 - Prob. 12RCh. 3 - Prob. 13RCh. 3 - Prob. 14RCh. 3 - Prob. 15RCh. 3 - Prob. 16RCh. 3 - Prob. 17CCh. 3 - Prob. 18CCh. 3 - Prob. 19CCh. 3 - Give examples of values for a and b in the...Ch. 3 - Suppose you are given an array, A, containing 100...Ch. 3 - Write a method, shuffle(A), that rearranges the...Ch. 3 - Suppose you are designing a multiplayer game that...Ch. 3 - Write a Java method that takes two...Ch. 3 - Prob. 25CCh. 3 - Prob. 26CCh. 3 - Prob. 27CCh. 3 - Prob. 28CCh. 3 - Prob. 29CCh. 3 - Prob. 30CCh. 3 - Prob. 31CCh. 3 - Prob. 32CCh. 3 - Prob. 33CCh. 3 - Prob. 34CCh. 3 - Prob. 35CCh. 3 - Write a Java program for a matrix class that can...Ch. 3 - Write a class that maintains the top ten scores...Ch. 3 - Prob. 38PCh. 3 - Write a program that can perform the Caesar cipher...Ch. 3 - Prob. 40PCh. 3 - Prob. 41PCh. 3 - Prob. 42PCh. 3 - Prob. 43P
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- write this java codearrow_forwardWe have been given a vehicle class (Image 1) that is a domain class in java and we want to create a vehicle service class named VehicleArrayIListlmpl (Image 2). The Service class will store multiple domain objects, support the implementation of the domain class, and include a java collection array list. Use java to create the VehicleArraylListImpl, with appropriate methods (based on the class diagram) Business rule - When adding a Vehicle, confirm the Vehicle is not present. Confirm the Owner does exist. If either does not pass, print a message to the console and stop the add. Use the isPresent method you created above VehicleArrayListImpl dava Enumeration OvehicleClassification f carShows List main VANTIQUE VehicleClossification VCLASSC VehicleClessification VuoCERN Vehicieclassification fvenicieCiassificationo m VehicleArrayListImpl() m add(Vehicle) boolean 1.1 m dump() m find(String) void cjava Classa @Wehicle Vehicle main vehicleD: String a pwnero String e manufacturer String a…arrow_forwardImplement the class as depicted in the UML diagram. Apartment -city: String -area: double -nbOfRooms: int -duplex: boolean +num apt: int +Apartment(----All data fields----) +getCity(): String +getNumberOfStories(): int +assessSize(): String +printDescription(): void 2/3 Data Fields: 1. city: It may consist of one word or two such as "Beirut", "Bint Jbeil", etc. 2. area: its value is expressed in square meter 3. nbOfRooms: with maximum value of 10 4. duplex: either true or false to reflect whether the apartment is made of two stories or only a single one. 5. num_apt: to keep track of how many apartment objects were created. Methods: 1. A constructor that creates an Apartment object with the specified values of all data fields. If the number of rooms passed is greater than 10, then nbOfRooms is set to 0. 2. getCity(): this method returns the city with its letters all capitalized. 3. getNumberOfStories(): This method returns the number of stories of an apartment. If it is duplex, then 2…arrow_forward
- use the design pattern for collecting objects. We are going to model a Orchard with trees. An Orchard uses an ArrayList to keep track of Tree objects. You will write both a Orchard class and a Tree class. A Tree has a type and a height. Provide a constructor that takes type and height, in that order. Provide getters and setters for the instance variables. This is the design pattern for managing properties of objects. An Orchard has a constructor that takes no parameters. Remember it must initialize the instance variable. It also has methods ○ add() Adds the specified Tree to the Orchard ○ tallest() Gets the type of the tallest Tree in the Orchard or null if the Orchard is empty. Initialize the tallest with the first element. ○ contains() determines if a Tree of the given type is in the Orchard. Returns true if a Tree of the given type is in the Orchard. Otherwise false. ○ treeList() gets an ArrayList<String> containing the types of all…arrow_forwardWrite a program that implements the algorithm delimiterMatching() seen in class.arrow_forwardThe implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forward
- When one class includes instances of another class, we say that the two classes are "composed" together. As a consequence, we now have a has-a connection. Have a look at the lengthy declaration: Inputsales.getHighestPaidEmployee(), inputsales.getHireDate(), and inputsales.getYear() ().arrow_forwardwrite program in java Design an abstract class GeometricObject. GeometricObject must ensure that its children must implement calcArea() method. Design RectangleYourRegNo and CircleYourName Classes as children of GeometricObject class with overridden toString() method to return “Rectangle with w Width and h Height is drawn” OR “Circle with r Radius is drawn”. The attributes of Rectangle are length, width. The attribute of Circle is radius Hint: Area of circle=πr2 , Area of rectangle= width*lengtharrow_forwardQuestion: Implement the following UML class diagrams and test their methods. Shape - dimension1 : double - dimension2 : double + Shape(d1: double, d2 : double) + setDimension1(d1: double) : void + setDimension2(d2 : double) : void + getDimension10 : double + getDimension20 : double + getName() : String + getArea) : double + toString() : String Circle Rectangle - circleld : int - circleCounter : int + Circle(radius : double) + setRadius(radius : double) : void + getRadius) : double + getCircleld) : int + getCircleCounter) : int + getName() : String + getArea() : double + toString) : String - rectangleld : int - rectangleCounter : int + Rectangle(side1 : double, side2 : double) + setSide1(side1 : double) : void + getSide10 : double + setSide2(side2 : double) : void + getSide20 : double + getRectangleld0 : int + getRectangleCounter0 : int + getName() : String + getArea() : double + toString) : Stringarrow_forward
- We have a parking office class for an object-oriented parking management system using java Add (implement )a method to the Parking Office c to return a collection of customer ids (getCustomerIds) using java I have attached two class diagrams with definitions of all related classes in our system (i.e car, customer, .....). N.B. Parking office methods in the class defination like register, getcustomer and addcharge have already been implemented, we just need an additional getcustomerID method as mentioned abovearrow_forwardWhen one class includes instances of another class, we say that the two classes are "composed" together. Thus, a has-a connection is established. Have a look at this lengthy declaration: Inputsales.getHighestPaidEmployee(), inputsales.getHireDate(), inputsales.getYear() ().arrow_forwardImplement abstraction on animal and car classes (in java) e.g animal and car is a abstract class.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning