Inheritance
Create a class named Book that contains data fields for the title and number of pages. Include get and set methods for these fields. Next, create a subclass named Textbook, which contains an additional field that holds a grade level for the Textbook and additional methods to get and set the grade level field. Write an application that demonstrates using objects of each class. Save the files as Book.java, Textbook.java, and DemoBook.java.
Class Design
a. Create a class named Commission that includes three variables: a double sales figure,
a double commission rate, and an int commission rate. Create two overloaded methods
named computeCommission() . The first method takes two double parameters
representing sales and rate, multiplies them, and then displays the results. The second
method takes two parameters: a double sales figure and an integer commission rate. This
method must divide the commission rate figure by 100.0 before multiplying by the sales
figure and displaying the commission.
Supply appropriate values for the variables, and write a main() method that tests each
overloaded method. Save the file as Commission.java.
Get Free Quote!
305 Experts Online