Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Below is source code to define a Person class. Examine the source code and answer the questions below: public abstract class Person { private

JAVA

Below is source code to define a Person class. Examine the source code and answer the questions

below:

public abstract class Person {

private String name;

private String gender;

private String address;

public Person(String name, String gender, String address){

this.name = name;

this.gender = gender;

this.address = address;

}

public String getName() {

return name;

}

public String getGender() {

return gender;

}

public String getAddress() {

return address;

}

public abstract void displayDetails();

}

Write source codes in the Java programming language to define Customer and Salesperson classes that inherits from the Person class defined in the above source code. The Customer class should have an additional attribute called amountSpent of double data type. The Salesperson class should have an additional method called calculateDiscount that takes customer object as an argument, calculates a 10% discount and returns double type. The displayDetails method of the Customer class should display a message which is different from that of the Salesperson class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago