Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8, Problem 10E
Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item. The method has two parameters, count and itemCost.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In Python,
#Create a basket class, which has a class/static attribute pricelist (string/float dictionary - you can hardcode this)
#The constructor should set the name to the name passed as a parameter and initialise the contents (empty)
#You should provide an addItem method taking product,quantity which adds this to the contents
#and a getQuantity method taking a product, which returns the relevant quantity
Create an abstract class DiscountPolicy. It should have a single abstractmethod computeDiscount that will return the discount for the purchase ofa given number of a single item. The method has two parameters, countand itemCost.
Create an abstract class called Employee that has an abstract method called calculatePay() which calculates the total pay per employee using the rate per hour = R100. The method should accept the number of hours the employee has worked. Create a child class called employeeChild and provide the implementation. In the main method invoke that method and get the number of hours worked from the user and pass it to the called method.
Chapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 8.1 - Prob. 1STQCh. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Can a derived class directly access by name a...Ch. 8.1 - Can a derived class directly invoke a private...Ch. 8.1 - Prob. 6STQCh. 8.1 - Suppose s is an object of the class Student. Base...Ch. 8.2 - Give a complete definition of a class called...Ch. 8.2 - Add a constructor to the class Student that sets...Ch. 8.2 - Rewrite the definition of the method writeoutput...
Ch. 8.2 - Rewrite the definition of the method reset for the...Ch. 8.2 - Can an object be referenced by variables of...Ch. 8.2 - What is the type or types of the variable(s) that...Ch. 8.2 - Prob. 14STQCh. 8.2 - Prob. 15STQCh. 8.2 - Consider the code below, which was discussed in...Ch. 8.2 - Prob. 17STQCh. 8.3 - Prob. 18STQCh. 8.3 - Prob. 19STQCh. 8.3 - Is overloading a method name an example of...Ch. 8.3 - In the following code, will the two invocations of...Ch. 8.3 - In the following code, which definition of...Ch. 8.4 - Prob. 23STQCh. 8.4 - Prob. 24STQCh. 8.4 - Prob. 25STQCh. 8.4 - Prob. 26STQCh. 8.4 - Prob. 27STQCh. 8.4 - Prob. 28STQCh. 8.4 - Are the two definitions of the constructors given...Ch. 8.4 - The private method skipSpaces appears in the...Ch. 8.4 - Describe the implementation of the method drawHere...Ch. 8.4 - Is the following valid if ShapeBaSe is defined as...Ch. 8.4 - Prob. 33STQCh. 8.5 - Prob. 34STQCh. 8.5 - What is an advantage of having the main...Ch. 8.5 - What Java construct allows us to define and...Ch. 8 - Consider a program that will keep track of the...Ch. 8 - Implement your base class for the hierarchy from...Ch. 8 - Draw a hierarchy for the components you might find...Ch. 8 - Suppose we want to implement a drawing program...Ch. 8 - Create a class Square derived from DrawableShape,...Ch. 8 - Create a class SchoolKid that is the base class...Ch. 8 - Derive a class ExaggeratingKid from SchoolKid, as...Ch. 8 - Create an abstract class PayCalculator that has an...Ch. 8 - Derive a class RegularPay from PayCalculator, as...Ch. 8 - Create an abstract class DiscountPolicy. It should...Ch. 8 - Derive a class BulkDiscount from DiscountPolicy,...Ch. 8 - Derive a class BuyNItemsGetOneFree from...Ch. 8 - Prob. 13ECh. 8 - Prob. 14ECh. 8 - Create an interface MessageEncoder that has a...Ch. 8 - Create a class SubstitutionCipher that implements...Ch. 8 - Create a class ShuffleCipher that implements the...Ch. 8 - Define a class named Employee whose objects are...Ch. 8 - Define a class named Doctor whose objects are...Ch. 8 - Create a base class called Vehicle that has the...Ch. 8 - Create a new class called Dog that is derived from...Ch. 8 - Define a class called Diamond that is derived from...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PPCh. 8 - Prob. 4PPCh. 8 - Create an interface MessageDecoder that has a...Ch. 8 - For this Programming Project, start with...Ch. 8 - Modify the Student class in Listing 8.2 so that it...Ch. 8 - Create a JavaFX application that uses a TextField...Ch. 8 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Describe the two ways in which control statements can be combined.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
In Exercises 31 and 32, complete the table by filling in the value of each variable after line is executed.
Introduction To Programming Using Visual Basic (11th Edition)
Consider the following skeletal C program: void fun1(void); / prototype / void fun2(void); / prototype / void f...
Concepts of Programming Languages (11th Edition)
Distinguish among data definition commands, data manipulation commands, and data control commands.
Modern Database Management
Explain the difference between redundancy and diversity.
Software Engineering (10th Edition)
Which of the following activities require real-time processing? a. Printing mailing labels b. Playing a compute...
Computer Science: An Overview (12th 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
- c# programMake a class called Employees, with attributes Name, Gender, Experience, Salary and ID.Make a delegate called EligiblePromo. This delegate takes an employees object as a parameter and returns a boolean value indication whether or not the employee should be promoted.Make a PromoteEmployee() method that takes an arraylist of Employees and delegate of type EligiblePromo as parametersNB: PromoteEmployee() methos loops through each Employees object and passes it to the delegate(25)arrow_forwardCreate abstract class Pet , which is the abstract superclass of all animals.Declare a integer attribute called legs, which records the number of legs for this animal.Define a constructor that initializes the legs attribute.Declare an abstract method eat.Declare a concrete method walk that prints out something about how the animals walks (include the number of legs).Create the Dog class.The Dog class extends the Pet class.This class must include a String attribute to store the name and food of the petDefine a default constructor that calls the superclass constructor to specify that all dogs have 4 legs and name.override the eat and walk method.Create the Cat class that extends Pet.This class must include a String attribute to store the name of the pet, and a string to save food .Define a constructor that takes one String parameter that specifies the cat's name and food. This constructor must also call the superclass constructor to specify that all cats have four legs.Override walk…arrow_forwardJava Program The assignment requires two classes. Put all classes in the same package. Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int Methods: Parameterized constructor for initializing a new Employee instance Getters for all attributes toString method to display an Employee's attributes (See output of executable below) Executable Class Create an array of at least eight Employee objects. Be sure to use many with identical last names, but don't order them by name in the array. Create an ArrayList from the array. Sort the ArrayList first by last name and then by first name. Using the forEach method and a lambda expression, print all employees alphabetically sorted by name. Create a LinkedList from the ArrayList. Create an iterator capable of cycling both forward and backward through the LinkedList. Iterate forward through the LinkedList without generating any output. Then iterate backwards through the LinkedList to print…arrow_forward
- Create a project to play a bunch of games. Add a class that has main() in it. Create an abstract class called Game. Define one instance variable for the name of the game. Define a constructor that takes the name of the game as a parameter and sets it. Define an abstract method called playGame. It takes no arguments and returns void. Create a child class of Game called BoardGame. Rather than implementing playGame, declare BoardGame abstract. Create a child class of BoardGame called Chess or Battleship or Monopoly or whatever board game you want. Implement the playGame with only a message that says the name of the game and that it is being played. Create a child class of Game called CardGame. Rather than implementing playGame, declare CardGame abstract. Create a child class of CardGame for War. Implement the playGame method by with a message that says the game of war is being played. Create a child class of Game called VideoGame. Rather than implementing playGame,…arrow_forwardCreate an abstract CardGame which contains a “deck” of 52 playing cards that uses a Card class that holds a suit and value for each Card object. It also contains an integer field that holds the number of cards dealt to a player in a particular game. The class contains a constructor that initializes the deck of cards with appropriate values (e.g., “King of Hearts”), and a shuffle() method that randomly arranges the positions of the Cards in the array. The class also contains two abstract meb. Create two child classes that extend CardGame. You can choose any games you prefer. For example, you might create a Poker class or a Bridge class. Create a constructor for each child class that initializes the field that holds the number of cards dealt to the correct value. (For example, in standard poker, a player receives five cards, but in bridge, a player receives 13.) Create an appropriate displayDescription() and deal() method for each child class.arrow_forwardpython programming Implement a constructor for the Person class Implement a constructor for the Student class Create a student with name; Albert Einstein, ramq: 14031879-1235, address: 112 Mercer Street, Princeton, courses: (1)Physics & (2)Relativity where the grades were b and a respectively and with enrollment date: 1895 partial solution attached in the imagearrow_forward
- Your assignment for this course is to implement a beginner level Book Management System (BMS) in Java language. BMS contains 2 classes: Bookand BookList. The Book class has the following attributes: code: a String object, that hold the book’s code. title: a String object, that hold the book’s title. qua: int variable, that hold the number of books with the same code in the library. price: a double variable, that hold the book’s price. The BookList class contains only one data member: ArrayList<Book> t. When running the program display the menu as below:1. Input & add book(s) to the end.2. Display all books.3. Search a book for given code.4. Update the book’s price for given code.5. Find the (first) max price value.6. Sort the list ascendingly by code.7. Remove the book having given code.8. Load data from file.0. Exit.Notes:(1) The book’s code must be unique in the list.(2) Display all books in format (code, title, quantity, price).(5)…arrow_forwardUsing polymorphism and object-oriented programming Design an Elevator simulation. The simulation have 4 different types of elevators and passengers. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request percentage of 70%.…arrow_forwardThis Java code involves implementing a simple university personnel management program. The program contains three kinds of objects: Staff, Student, and Faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of object. For example, a student has a gpa, a faculty has a title and department (professor, mathematics). For each of any class data member, your program must include the getters and the setters, and each class must include at least two constructors. The main goal of this code is to demonstrate the use of inheritance, abstract classes, abstract methods, and method overriding. The Student class has the private attributes:- full name : String- id: String- gpa: double- Number of credit hours currently taken: int For a faculty, we need a: - full name: String- id: String- department (mathematics, engineering or english): String- Rank (professor or adjunct): String For a staff,…arrow_forward
- Design a console program that will print details of DVDs available to buy. Make use of an abstract class DVD with variables that will store the title, yearReleased, running time and price of a DVD. Create a constructor that accepts the title, yearReleased and running time through parameters and assign these to the class variables. Create an abstract set method for the price of a DVD; also create get methods for the variables.Create a subclass InstructionalDVD that extends the DVD class and implements an iPrintable interface. The interface that must be added is shown below:public interface iPrintable { String ShowDetails();}The InstructionalDVD subclass has a private variable named category for which a get method must be written. The constructor of the InstructionalDVD class must accept the title, yearReleased, running time and category through parameters. Write the code for the setPrice() and ShowDetails() methods.Write a useDVD class and instantiate 2 objects of the InstructionalDVD…arrow_forwardA SuperDie Class Write a class SuperDie that models a single die with an arbitrary number of sides, not just six. A die instantiated with the default constructor has six sides. The methods of this class should be: • roll a die and return its value, • return the number of sides on a die, and • change the number of sides on a die. Include a main(...) method that tests all the methods of your class.arrow_forwardAbstract in Java Employee Override the display method in the Person class override the toString() and equals() methods Define method earnings as abstract with a return type of double. Hourly Employee provide the setters and getters of your data members provide call to parent contructors earnings is computed by having the product of the total number of hours worked and the rate. but if the number of hours worked exceeds 40, the rate increases to 150% of the current rate. (ex. rate=200; 150% = 300) override the toString() and equals() methods Note:Class Person is already loaded in this activity. No need to add the class in your code.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,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ 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,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License