Question: Write a program in java language so as to make use of inheritance as follows: A car dealership requires a program that tracks down the
Write a program in java language so as to make use of inheritance as follows: A car dealership requires a program that tracks down the following data:
- A Purchaser is a customer that has purchased a car and has a monthly payment (double) to make.
- A Service customer is one who has had their car serviced at the dealership in the last month, and has a service date (string) as well as an invoice amount (double).
Derive the above two classes from a base class Customer which has a customer name (string) as a data member. Each derived class will have functions called getData() and showData() to read and display their data.
In main, there should be a loop that continues as long as the user wishes. Inside the loop, the user is asked what type of customer is to be added, and an object is then created and stored in an array. The getData() function is then called to populate the object and the showData() is called to display the objects data.
Have the showData() function return a value. The Purchaser showData() function will return zero. The Service customer showData() function will return the invoice amount. These values should be summed in main() to find the total of all the monthly invoices of the Service customer objects. This total should then be displayed.
write comments so I can understand
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
