design an estate agent sales class that must contain a constructor to accept the estate agent name and property sale amount as parameters and write a code for the print property report method which prints agent name; property sale price and the state agent commission amount

1 answer

Here is an example implementation of an EstateAgentSales class based on your requirements:

```java
public class EstateAgentSales {
private String agentName;
private double saleAmount;
private double commissionAmount;

public EstateAgentSales(String agentName, double saleAmount) {
this.agentName = agentName;
this.saleAmount = saleAmount;
this.commissionAmount = calculateCommission();
}

public void printPropertyReport() {
System.out.println("Agent Name: " + agentName);
System.out.println("Property Sale Price: $" + saleAmount);
System.out.println("Agent Commission Amount: $" + commissionAmount);
}

private double calculateCommission() {
// Assuming the commission rate is 5% of the sale amount
double commissionRate = 0.05;
return saleAmount * commissionRate;
}

// Getters and Setters for agentName, saleAmount, and commissionAmount

public String getAgentName() {
return agentName;
}

public void setAgentName(String agentName) {
this.agentName = agentName;
}

public double getSaleAmount() {
return saleAmount;
}

public void setSaleAmount(double saleAmount) {
this.saleAmount = saleAmount;
this.commissionAmount = calculateCommission();
}

public double getCommissionAmount() {
return commissionAmount;
}

public void setCommissionAmount(double commissionAmount) {
this.commissionAmount = commissionAmount;
}
}
```

You can use this class as follows:

```java
public class Main {
public static void main(String[] args) {
EstateAgentSales agentSales = new EstateAgentSales("John Doe", 250000.0);
agentSales.printPropertyReport();
}
}
```

Output:
```
Agent Name: John Doe
Property Sale Price: $250000.0
Agent Commission Amount: $12500.0
```

In this example, the commission amount is calculated as 5% of the sale amount, but you can modify the `calculateCommission` method to use a different calculation based on your requirements.