Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 21C
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a C++ class and choose any name for it. The class should have two privatemembers and two public members. Write a constructor to initialize these membersto zero. Write another constructor to initialize these members to non-zero values.Write a method to return the average of the class members. Write a C++ programand initialize the members of the class with [2,5,8,3] respectively and call its methodto calculate the average.
1. Create a Student class that implements the Person interface. As well as storing the students name and email, also store their course grade (e.g A, B, C) in a member variable. The grade should be accessible via a getGrade method. For the implementation of getDescription return a message along the lines of “A C grade student”, substituting the students actual grade.2. Create a Lecturer class that implements the Person interface. This class should also store the subject that the lecturer teaches. Add a getSubject method, and implement getDescription so that it returns a suitable message, e.g. “Teaches Biology”.3. Create a third class, Employee that implements the interface. This should also store the name of the department the Employee works in (available via getDepartment). Again, getDescription should return a suitable message.
language is c++
sample output included with user input in bold
Chapter 2 Solutions
Data Structures and Algorithms in Java
Ch. 2 - Give three examples of life-critical software...Ch. 2 - Give an example of a software application in which...Ch. 2 - Prob. 3RCh. 2 - Prob. 4RCh. 2 - Prob. 5RCh. 2 - Give a short fragment of Java code that uses the...Ch. 2 - Prob. 7RCh. 2 - Prob. 8RCh. 2 - Prob. 9RCh. 2 - Prob. 10R
Ch. 2 - Prob. 11RCh. 2 - Draw a class inheritance diagram for the following...Ch. 2 - Prob. 13RCh. 2 - Prob. 14RCh. 2 - If the parameter to the makePayment method of the...Ch. 2 - Prob. 16CCh. 2 - Most modern Java compilers have optimizers that...Ch. 2 - The PredatoryCreditCard class provides a...Ch. 2 - Modify the PredatoryCreditCard class so that a...Ch. 2 - Prob. 20CCh. 2 - Write a program that consists of three classes, A,...Ch. 2 - Prob. 22CCh. 2 - Prob. 23CCh. 2 - Write a Java class that extends the Progression...Ch. 2 - Redesign the Progression class to be abstract and...Ch. 2 - Use a solution to Exercise C-2.25 to create a new...Ch. 2 - Use a solution to Exercise C-2.25 to reimplement...Ch. 2 - Write a set of Java classes that can simulate an...Ch. 2 - Write a Java program that inputs a polynomial in...Ch. 2 - Write a Java program that inputs a document and...Ch. 2 - Prob. 31PCh. 2 - Write a Java program that simulates a system that...Ch. 2 - Define a Polygon interface that has methods area()...Ch. 2 - Prob. 35PCh. 2 - Write a Java program that can make change. Your...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing the Digital Firm (15th Edition)
Empl Id Name Address SSN Job Id Job Title Skill Cod Dept Start Date Term Date 25X15 Joe E. Baker 33 Nowhere St ...
Computer Science: An Overview (12th Edition)
Identify the syntactic errors in the following program. Then type in and run the corrected program to ensure yo...
Programming in C
The article mentions that quantum computers will have tremendous processing power and revolutionize a number of...
Using MIS (10th Edition)
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
- In C++ Language using Functions and Pointers PROBLEM: Consider the elevator in the Faculty of Engineering (5 storey). Write a program which accepts the floor number where a passenger (student/faculty/other personnel) will ride the elevator. The passenger can then input the target destination floor. SPECIFICATIONS: Implement the class diagram below: Inside the main method, create an instance of the class Elevator. Use the goUp or goDown methods to generate the program display.Passenger can ride in any floor (1,2,3,4 or 5). Program will prompt the user with the target destination floor. After the user input: Program will display the floors which the elevator passes through, and finally the destination floor. Elevator will not move if the input for destination floor is the same as the present floor. Program will notify the user and then terminate. Program will also terminate if the input destination is not 1,2,3,4 or 5. You’re free to format the input/output display. Observe proper…arrow_forwardWrite in python and please include docstring. Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It should have an init method that takes four values and uses them to initialize the data members. It should have get methods named get_name, get_ID_number, get_salary, and get_email_address. Write a separate function (not part of the Employee class) named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object. It should do the same with the second value of each list, etc. to the end of the lists. As it creates these objects, it should add them to a dictionary, where the key is the ID number and the value for that key is the whole Employee object. The function should return the resulting dictionary. For example, it…arrow_forwardPart (1) Define a class as follow: a. create a class called Student that has four instance variables - a (String) name, a (long) StudentID, a (String) College, and a (double) GPA. b. A constructor that takes student name, StudentID, College and GPA. The constructor sets the class variables to these values . c. Make the instance variable GPA private and provide a mutator method (set) and an accessor method (get) to access this variable. In set method if the GPA negative or grater than 4.00 print an invalid message and do not change the instance variable GPA. d. A method Student_Status () that check the GPA if it is less than 2, display the warning message, otherwise display Normal student. e. A method Print() that displays the name, StudentiD, College and GPA of the student as shown below: Sample output: Enter the Student name: ALİ Ahmed Enter the Student ID: 20180011 Enter the College: Information Technology Enter the GPA: 3.2 Normal student Name: Ali Ahmed Student ID: 2018ee11…arrow_forward
- 82. Write a class definition for a class named Fraction that contains two integer fields named numerator and denominator. Include in the class a prototype for a method (function) named add that takes two Fraction objects as input arguments and returns a Fraction object as output. You do not need to provide an implementation of the add method.arrow_forwardLanguage is C++ Assignment 8 B: Hit Boxes (Part 2). Back in Assignment 2 (so long ago!) we created a simple program to determine what a hit box would be. Now we’re going to use that information to determine if two characters would collide based on those hit boxes.You will create a Player class that takes in the following private attributes (as integers) when creates Width Height X position Y position In addition to Getter methods for all four attributes, the Player class should also have the following methods: MoveHorizontal(int x_delta)◦ Takes in either a negative integer (for moving left) or a positive integer (for moving right). It should update the X position of the Player object MoveVertical(int y_delta)◦ Takes in either a negative integer (for moving down) or a positive integer (for moving up). It should update the Y position of the Player object DidTheyCollide(Player otherPlayer)◦ Takes in another player object, and returns true if they collided with each other (and…arrow_forwardNovice: How can i access a main class objects from outside the function? / Better Alternative? If i have 4 Student objects how can i print the information for the specific object given one parameter about the class, like the students Idnumber. What i came up with was making a checkId void function that takes the user input and runs an if else chain checking if the Id belongs to student 1-4 then printing the details of that classes object with the void function print. ideally i would want the if-else chain in the checkId function to call the print( student1-4) class object but im not sure how to properly do that. i dont think this is the best way to go about it, if you have any recommendations or alternatives please help me out.arrow_forward
- Write the definition of a class Counter containing: • An instance variable named counter of type int. • An instance variable named limit of type int. • A static int variable named nCounters which is initialized to 0. • A constructor taking two int parameters that assigns the first one to counter and the second one to limit. It also adds one to the static variable nCounters. ● A method named increment. It does not take parameters or return a value; if the instance variable counter is less than limit, increment just adds one to the instance variable counter. • A method named decrement that also doesn't take parameters or return a value; if counter is greater than zero, it just subtracts one from the counter. • A method named getValue that returns the value of the instance variable counter. • A static method named getNCounters that returns the value of the static variable nCounters.arrow_forwardProblem C • -3: method consonants() had more than one loop • -3: method initials () had more than one loop • -3: at least one method used nested loopsarrow_forwardDesign and implement a data class. The class will store data that has been read asuser input from the keyboard (see Getting Input below), and provide necessary operations. As the data stored relates to monetary change, the class should be named Change. The class requires at least 2 instance variables for the name of a person and the coin change amount to be given to that person. You may also wish to use 4 instance variables to represent amounts for each of the 4 coin denominations (see Client Class below). There should be no need for more than these instance variables. However, if you wish to use more instance variables, you must provide legitimate justification for their usage in the internal and external documentation. Your class will need to have at least a default constructor, and a constructor with two parameters: one parameter being a name and the other a coin amount. Your class should also provide appropriateget and set methods for client usage. Other methods may be provided as…arrow_forward
- For C++ Programming II D.S. Malik Programming Exercise 10-16: Write the definition of a class swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool. Add appropriate constructors to initialize the instance variables. Also, add member functions to do the following: determine the amount of water needed to fill an empty or partially filled pool, determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time, if the water in the pool exceeds the total capacity of the pool, output "Pool overflow" to indicate that the water has breached capacity. The header file for the swimmingPool class has been provided for reference. Write a program to test your…arrow_forwardC++ OOP use classes only...arrow_forwardIn python how do you: Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None:…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License