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 8E
Create an abstract class PayCalculator that has an attribute payRate given in dollars per hour. The class should also have a method computePay(hours) that returns the pay for a given amount of time.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle with abstract methods getColor () and getBrand (). Now, create a concrete class Taxi with additional method setDriver (String name) that inherits both Wheel and Vehicle. (Note: Concrete classes don’t have any abstract method)
Write in java an abstract class Student that includes the following hidden attributes: id(int), name(String), major(String) and grade(double), then create setter and getter for each of them. Write two classes that inherited from Student: ItStudent and ArtStudent. The grade for ItStudent is calculated as: grade = mid*0.30 + project*0.30 + final*40 and the grade for ArtStudent is calculated as: grade = mid*0.40 + report*0.10 + final*50. Crate main class that achieve the following:a. Create an array of some Student objects from both ItStudent and ArtStudent classes.b. Sort the Student objects by grade in descending order using functions.c. Save the sorted objects into file.
Create 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.
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 four basic elements of counter-controlled iteration.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
24. If we increase the temperature in a reactor by 90 degrees Fahrenheit [°F], how many degrees Celsius [°C] wi...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
2-1 List the five types of measurements that form the
basis of traditional ptane surveying-
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Modify the Product_T table by adding an attribute QtyOnHand that can be used to track the finished goods invent...
Modern Database Management
Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over...
Starting Out with C++ from Control Structures to Objects (9th Edition)
In Exercises 33 through 40, determine the output displayed in the list box by the lines of code. DimtotalOunces...
Introduction To Programming Using Visual Basic (11th 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
- 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.arrow_forwardDo it in C# windows application form.arrow_forwardCreate a Dog and a Cat class, each of which inherit from Animal. Each class should have a constructor which initialses their name and a hello method. The cat's hello method should return the string "Meow" and the dog's hello method should return the string "Woof". The Animal class is public abstract class Animal { public Animal(String n) { name = n; } abstract String hello(); public String greeting() { return hello() + ", I am + name; } // private private String name; } Your classes will be used in the following Main class. public class Main { public static void main(String [] args) { Animal cat = new Cat("Angel"); Animal dog = new Dog("Fido"); System.out.println(cat.greeting()); System.out.println(dog.greeting()); } } Note that your Cat and Dog classes must not supply a greeting method. They should use the greeting method from the Animal class.arrow_forward
- Implement a JAVA application that keeps track of package deliveries to consumers. Theapplication consists of the following classes:• Item: Create a class called Item. The class has two member variables oftype String named name and description and provides getter and settermethods for both.• Mail (abstract class): Implement an abstract class called Mail . The class hasa member variable of type String named address and a getter method for it.• Letter: Implement a class called Letter that inherits from Mail . The classhas one member variable of type String named contents.• Package: Implement a class called Package that inherits from Mail . Theclass has one member variable of type Item[] named items and a gettermethod for it.• DeliveryTruck: Implement a class called DeliveryTruck with a singlemember variable of type Mail[] of length 10. Add the following method:o void load(Mail mail): This method stores the given mail argumentat the next available spot in the member variable.arrow_forwardCreate 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_forwardInstructions: Write your answer on a piece of paper with your name on top. Take a picture and submit within the allocated time limit. Problem 1: Implement class Employee as illustrated below. Apply appropriate constructors, encapsulate, and override toString and equals. Student Course Problem 2: «interface Payable abstract Employee Person SalariedEmployee Idno Name Employee Superclass Department Salary Subclass getPayment Amount() firstName, lastName, SSN weeklysalary Given the class hierarchy: 1. Define the interface Payable. 2. Define the class Employee that implements Payable and encapsulate. 3. Define SalariedEmployee and encapsulate. Implement getPayment Amount(). getPayment Amount() - returns a double amount that must be paid for an object of any class that implements the interface. For SalariedEmployee, it would just return the value returned by getWeeklySalary(). for new files: 128MBarrow_forward
- Implement the following parking permit class using java It has a dependency on the car class, no need to implement the car class. Use the diagram for refrencearrow_forwardNeed help on java homework assignment, It says Create a class Vehicle. A Vehicle has a single instance variable of type String named "vehicleType" that describes the vehicle. It has an abstract method getTires that takes no parameters and returns an ArrayList<Tire> object that describes each Tire of the vehicle. A Tire class has been provided. Vehicle has a single constructor that takes the vehicle type as a parameter.Create a class Bicycle that extends Vehicle that has two Tires, both of type "skinny". Bicycle should have a single default constructor.Create a class Dragster that extends Vehicle and has four Tires, two of type "slick" and two of type "medium". Dragster should have a single default constructor.Write a tester program to test Bicycle and Dragster objects. Use declarations such as Vehicle b = new Bicycle();in your tester. Here is the code provided : public class Tire { private String size; public Tire(String siz) { size = siz; } public String…arrow_forwardCreate a random player that can make valid random moves. Extend the base class Player to create a new class class Player {protected: string name; int type;public: Player(string i, int t): name(i), type(t) {} int getType() {return type;} virtual string getPlayerName() {return name;} virtual bool getMove(Board board, int& x, int& y) = 0; virtual ~Player() {}};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_forwardYour 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_forwardWrite the classes as shown in the following class diagram. Add a tester that asks the user for a cat, dog and a BigDog then call all of their methods. Note that Cat and Dog inherit from the abstract class Animal and BigDog inherits from Dog.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 - CONSIGNMENT
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
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License