Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
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 (7th 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 the difference between what you can do in...Ch. 8.5 - Prob. 36STQCh. 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 - Prob. 8PPCh. 8 - Prob. 9PPCh. 8 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the output produced by the following? Stringtest=abcdefg;System.out.printlntest.length();System.out.pri...
Absolute Java (6th Edition)
What is direct recursion? What is indirect recursion?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Fat Percentage Calculator Create an application that allows the user to enter the number of calories and fat gr...
Starting Out With Visual Basic (8th Edition)
Write Java statements to accomplish each of the following tasks: Test whether variable count is greater than 10...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
What is the purpose of an objects sizing handles?
Starting out with Visual C# (4th 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
- The total cost of a group of items at a grocery store is based on the sum of the individual product prices and the tax (which is 5.75%). Products that are considered “necessities” are not taxed, whereas products that are considered “luxuries” are. The Product class is abstract, and it has a method called getTotalPrice. Your task is to create two subclasses of Product: NecessaryProduct and LuxuryProduct and implement the getTotalPrice method in each of these classes appropriately. Then modify the driver program to instantiate four products (two necessary and two luxury) and store them in the product array, print out each item in the array, and display the total cost of the items. You should not make any changes at all to Product.java, and you should only add to ShoppingTripStartingCode.java. Do not change any code that is already present Example(Cheese and bread are necessities and soda and candy are luxuries)Cheese…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_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_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