Concept explainers
Java you should have one homework.java file
For this problem set, you will submit a single java file named Homework.java. You are supposed to add the functions described below to your Homework class. The functional signatures of the functions you create must exactly match the signatures in the problem titles. You are not allowed to use any 3rd party libraries in the homework assignment nor are you allowed to use any dependencies from the java.util package besides the Pattern Class. When you hava completed your homework, upload the Homework.java file to Grader Than. All tests will timeout and fail if your code takes longer than 10 seconds to complete.
privateFunction()
This is a private non-static function that takes no arguments and returns an integer.
You don't need to put any code in this function, you may leave the function's code empty. Don't overthink this problem. This is to test your knowledge on how to create a non-static private function.
Arguments:
returns int - You may choose any integer you would like.
protectedFunction(String, int)
This is a protected non-static function that takes a String and an int as its arguments and returns nothing.
You don't need to put any code in this function, you may leave the function's code empty. Don't overthink this problem. This is to test your knowledge on how to create a non-static protected function.
Arguments:
String text - An string
String int - An integer
mergeAndRemove(int[], int[])
This is a public static function that takes a int[] and int[] for the parameters and returns an int[].
Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.
Arguments:
int[] array_1 - An array of integers
int[] array_2 - An array of integers
returns int[] - An array of integers containing the unique values from both array_1 and array_2
Example:
array_1 = [1,2,3] array_2 = [2,3,4] output = [1,2,3,4]
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images
- Write a string class. To avoid conflicts with other similarly named classes, we will call our version MyString. This object is designed to make working with sequences of characters a little more convenient and less error-prone than handling raw c-strings, (although it will be implemented as a c-string behind the scenes). The MyString class will handle constructing strings, reading/printing, and accessing characters. In addition, the MyString object will have the ability to make a full deep-copy of itself when copied. Your class must have only one data member, a c-string implemented as a dynamic array. In particular, you must not use a data member to keep track of the size or length of the MyString. #include "mystring.h" #include <cctype> #include <iostream> #include <string> using namespace std; using namespace cs_mystring; void BasicTest(); void RelationTest(); void CopyTest(); MyString AppendTest(const MyString& ref, MyString val); string boolString(bool…arrow_forwardPlease help me with this assignment below. I already have the code, you just need to fix something or add something in the code as what the assignment below requests. The assignment: Continue Exercise •• P13.1, checking the words against the /usr/share/dict/words on your computer, or the words.txt file in the companion code for this book. For a given number, only return actual words. The code of the resource class: import java.util.Scanner; public class U10P01R{ // This method to returns a character array containing all possible keypad // encodings for a digit in a standard phone char[] keysForButton(int n) { switch (n) { case 0: return new char[] { ' ' }; case 1: return new char[] { '.' }; case 2: return new char[] { 'A', 'B', 'C' }; case 3: return new char[] { 'D', 'E', 'F' }; case 4: return new char[] { 'G', 'H', 'I' }; case 5: return new char[] {…arrow_forwardJAVA Problem – CycleFileOutput Revisit the Cycle class. Modify your application such that the properties will be written to a text file called “Cycle.txt” instead of to the screen. Directions Examine your application for the class called Cycle. Add an appropriate throws statement in the main method. Create a reference to a File class with the appropriate name of a text file (Cycle.txt). Use appropriate code to ensure that the text file exist. Output the values of the variables to the text file. Close the file. Note: Verify the contents were written to the text file using notepad (or any word processor). public class Cycle { // Declear integer instance variable private int numberOfWheels; private int weight; // Constructer declear class public Cycle(int numberOfWheels, int weight ) { this.numberOfWheels = numberOfWheels; this.weight = weight; } // String method for output public String toString() { String wheel = String.valueOf(this.numberOfWheels); String load =…arrow_forward
- In this java assignment, we will be creating a pay stub for an employee using classes. Each class must be implemented into their own file, a total of 5 classes/files. We are going to implement the following classes: Employee – This class represents an employee. It needs the following fields exposed via getters and setters: Employee ID (we will need to make this unique, for now, just hard code it to 1). First name, Last name, Middle initial Address, City, Zip Phone, Email Hourly Rate PayPeriod – This class represents an employee’s payment information. An employee will eventually have more than one pay period. It must contain the following fields (exposed via getters and setters): Pay period Id (hard code it for now) Employee Id (who is this for) Start Date, End Date Number of hours PayrollManager – This class provides the functionality we need to compute and display our payroll. It should implement the following methods: double CalculateGrossPay (Employee, Payperiod) – This…arrow_forwardIn python, must have docstrings Thank youarrow_forwardin python. For this project, you will import the json module. Write a class named NobelData that reads a JSON file containing data on Nobel Prizes and allows the user to search that data. Your code does not need to access the internet. Your class should have: an init method that reads the file and stores it in whatever data member(s) you prefer. Any data members of the NobelData class must be private. a method named search_nobel that takes as parameters a year and a category, and returns a sorted list (in normal English dictionary order) of the surnames for the winner(s) in that category for that year (up to three people can share the prize). The year will be a string (e.g. "1975"), not a number. The categories are: "chemistry", "economics", "literature", "peace", "physics", and "medicine". For example, your class could be used like this: nd = NobelData() nd.search_nobel("2001", "economics")arrow_forward
- To use any of the prewritten classes besides those in the java.lang package, you must___ a. use the entire path with the class name b. import the class c. import the package of which the class you are using is a part d. use any of these methodsarrow_forwardWritten in Python with docstring please if applicable Thank youarrow_forwardAs the first step in writing an application for the local book store, we will design and implement a Book class that will define the data structure of the application. Each book has a name, author, type (paperback, hardback, magazine), integer ID and pageCount. Provide some data validation in the appropriate method to ensure that the ID and pageCount are not negative. Design and implement a Book class with separation, i.e., separate all functions and methods into both the prototype and an implementation below the main. Provide constructor methods for Book(void), Book(name, author), and one for all components Book(name, author, type, ID, pageCount) Provide accessor (get and set) methods for each property as well as a display method. Provide data validation for the ID and pageCount in the appropriate methods. Provide a method to calculate the cost for buying books (with a 7.75% sales tax) according to the following chart: Hardcover: $29.95 per book Paperback:…arrow_forward
- This is the information after the two pictures. Also, your class should be placed in a namespace "cs_sequence". Here is an example of a simple client program, to give you an idea about how sequences might be used. You can also use this to test your class, but it's far from exhaustive. Keep in mind as you write your class that you should test each member function after you write it. int main() { Sequence s; for (int i = 0; i < 6; i++) { s.insert(i); } for (s.start(); s.is_item(); s.advance()) { cout << s.current() << " "; } cout << endl; } This client program will print the numbers 5 4 3 2 1 0. (They are backward because insert() inserts each new item at the front of the list.) Implementation We will be using the following implementation of type Sequence, which includes 5 data members. numItems. Stores the number of items in the Sequence. headPtr and tailPtr. The head and tail pointers of the linked list. If the Sequence has no items, then these pointers are…arrow_forwardIn C++ Create a new project named lab8_1. You will be implementing two classes: A Book class, and a Bookshelf class. The Bookshelf has a Book object (actually 3 of them). You will be able to choose what Book to place in each Bookshelf. Here are their UML diagrams Book class UML Book - author : string- title : string- id : int- count : static int + Book()+ Book(string, string)+ setAuthor(string) : void+ setTitle(string) : void+ print() : void+ setID() : void And the Bookshelf class UML Bookshelf - book1 : Book- book2 : Book- book3 : Book + Bookshelf()+ Bookshelf(Book, Book, Book)+ setBook1(Book) : void+ setBook2(Book) : void+ setBook3(Book) : void+ print() : void Some additional information: The Book class also has two constructors, which again offer the option of declaring a Book object with an author and title, or using the default constructor to set the author and title later, via the setters . The Book class will have a static member variable…arrow_forwardThe goal for Lab06a is to use the provided Student class and create an array of Student objects that are stored in a School object. This program uses a Student class that is provided See the work area. The class is placed in its own separate file and should not be altered. The Lab06avst.java file is also provided for you in the work area. You will not see the Student class here. There is evidence that the Student class is used, as you see in line 17, but the class is separate in its own file, which is better Object Oriented Design. Specifics and Output 10 Student objects need to be constructed and placed in a students array, which is stored in a School object. The actual data used in the Student objects can be seen by the output below. This program requires the completion of the School constructor. It also requires the completion of the addData method. This method does a lot. First you need to create three initializer lists for names, ages and gpas. These arrays are only used to…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education