Problem

Visit www.myprogramminglab.com to complete select exercises online and get instant feedbac...

Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.

Exercise

Programming Project 3 required rewriting the solution to Programming Project 2 with inheritance. Redo or do Programming Project 3, but instead define the Pet class as an abstract class. The acepromazine() and carprofen() methods should be defined as abstract methods.

In your main method, define an array of type Pet and add two instances of cats and two instances of dogs to the array. Iterate through the array and output how much carprofen and acepromazine each pet would require.

Project 3

Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.

Exercise

Programming Project 1 required adding an instance variable to the Pet class defined in Display 1 to indicate if the pet is a dog or cat. A better organization is to define Pet as a superclass of the Dog and Cat classes. This organization eliminates the need for an instance variable to indicate the type of the pet. Do or redo Programming Project 1 with inheritance. The acepromazine() and carprofen() methods should be defined in the Pet class to simply return 0. Override both methods in the Dog and Cat classes to calculate the correct dosage. Write a main method with appropriate tests to exercise the changes.

Project 1

Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.

Exercise

Your vet’s office is using the Pet class defined in Display 1 and would like to include a way to calculate the dosage amount for drugs that are commonly administered for dogs and cats. Make the following modifications to the class:

• Add an instance variable that indicates if the type of the pet is a dog or a cat.

• Modify the constructor and the set method to include the type of pet (i.e., dog or cat).

Add a method named acepromazine() that returns as a double the dosage in ml for the sedative acepromazine.

Add a method named carprofen() that returns as a double the dosage in ml for the pain killer carprofen.

The dosage calculation is

Weight is in pounds.

•For acepromazine, use mg per ml = 10, and mg per kg = 0.03 for dogs and 0.002 for cats.

For carprofen, use mg per ml = 12, and mg per kg = 0.5 for dogs and 0.25 for cats.

Modify the main method in Display 2 to include tests of the new methods.

Display 1

A Class for Pet Records

Display 2

Using Constructors and Set Methods

Project 2

Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.

Exercise

Your vet’s office is using the Pet class defined in Display 1 and would like to include a way to calculate the dosage amount for drugs that are commonly administered for dogs and cats. Make the following modifications to the class:

• Add an instance variable that indicates if the type of the pet is a dog or a cat.

• Modify the constructor and the set method to include the type of pet (i.e., dog or cat).

Add a method named acepromazine() that returns as a double the dosage in ml for the sedative acepromazine.

Add a method named carprofen() that returns as a double the dosage in ml for the pain killer carprofen.

The dosage calculation is

Weight is in pounds.

For acepromazine, use mg per ml = 10, and mg per kg = 0.03 for dogs and 0.002 for cats.

For carprofen, use mg per ml = 12, and mg per kg = 0.5 for dogs and 0.25 for cats.

Modify the main method in Display 2 to include tests of the new methods.

Display 1

A Class for Pet Records

Display 2

Using Constructors and Set Methods

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8