Develop a Java application and use a two-dimensional array that will store three property sales for

two estate agents for January, February, and March. In your solution, include the total property
sales and the 2% commission earned by each estate agent. You are also required to display the
top-selling estate agent.

Your program must:
1. Contain a two-dimensional array to contain three property sales for January, February,
and March for two different estate agents.

ESTATE AGENT 1: Joe Bloggs
JAN: R800 000
FEB: R 1 500 000
MAR: R 2 000 000

ESTATE AGENT 2: Jane Doe
JAN: R 700 000
FEB: R 1 200 000
MAR: R 1 600 000

2. Calculate and print the total property sales for each estate agent.

3. Calculate and print the total 2% commission earned by each estate agent.

Sample Screenshot:

ESTATE AGENT SALES REPORT
JAN FEB MAR
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Joe Bloggs R 800 000 R 1 500 000 R 2 000 000
Jane Doe R 700 000 R 1 200 000 R 1 600 000

The total property sales for Joe Bloggs = R 4 300 000
The total property sales for Jane Doe = R 3 500 000

Sales commission for Joe Bloggs = R 86 000
Sales commission for Jane Doe = R 70 000

Top performing estate agent: Joe Bloggs

4. Make use of a class named EstateAgent that contains methods to calculate estate agent
sales, estate agent commission, and the top-performing estate agent. The EstateAgent
class must implement an IEstateAgent interface that contains the following:
public interface IEstateAgent {
double EstateAgentSales(double[] propertySales);
double EstateAgentCommission(double propertySales);
int TopEstateAgent(double[] totalSales);
}

5. You are required to write unit tests for the application. Create a test package within the
application you created, which will contain the necessary unit tests.
You are required to write the following unit tests:

Test Name: CalculateTotalSales_ReturnsTotalSales()
Test Purpose: To supply the property sales to the
estate agent sales method. The test
will determine that the correct total
sales value is returned from the estate
agent sales method

Test Name: CalculateTotalCommission_ReturnsCommission()
Test Purpose: To supply a total property sales
amount to the estate agent
commission method. The test will
determine that the correct estate
agent commission has been
calculated.

Test Name: TopAgent_ReturnsTopPosition()
Test Purpose: To supply total sales for each estate
agent to the top estate agent method.
The test will determine the top selling
total property sales for the estate
agent

You can use the following code to implement the Java application:

First, create a class named "EstateAgent" that implements the "IEstateAgent" interface:

```java
public class EstateAgent implements IEstateAgent {
private String name;
private double[] propertySales;

public EstateAgent(String name, double[] propertySales) {
this.name = name;
this.propertySales = propertySales;
}

@Override
public double EstateAgentSales(double[] propertySales) {
double totalSales = 0;
for (double sale : propertySales) {
totalSales += sale;
}
return totalSales;
}

@Override
public double EstateAgentCommission(double propertySales) {
return 0.02 * propertySales;
}

@Override
public int TopEstateAgent(double[] totalSales) {
int topAgent = 0;
double highestSales = totalSales[0];
for (int i = 1; i < totalSales.length; i++) {
if (totalSales[i] > highestSales) {
highestSales = totalSales[i];
topAgent = i;
}
}
return topAgent;
}
}
```

Next, create a class named "Main" to display the sales report and calculate the total sales, commission, and top estate agent:

```java
public class Main {
public static void main(String[] args) {
// Create two estate agents
double[] agent1Sales = {800000, 1500000, 2000000};
EstateAgent agent1 = new EstateAgent("Joe Bloggs", agent1Sales);

double[] agent2Sales = {700000, 1200000, 1600000};
EstateAgent agent2 = new EstateAgent("Jane Doe", agent2Sales);

// Calculate total sales and commission for each estate agent
double agent1TotalSales = agent1.EstateAgentSales(agent1Sales);
double agent1Commission = agent1.EstateAgentCommission(agent1TotalSales);

double agent2TotalSales = agent2.EstateAgentSales(agent2Sales);
double agent2Commission = agent2.EstateAgentCommission(agent2TotalSales);

// Determine the top performing estate agent
double[] totalSales = {agent1TotalSales, agent2TotalSales};
int topAgent = agent1.TopEstateAgent(totalSales);

// Display the sales report
System.out.println("ESTATE AGENT SALES REPORT");
System.out.println("JAN\tFEB\tMAR");
System.out.println("--------------------------------------------------------------");
System.out.println(agent1.getName() + "\t" + formatCurrency(agent1Sales[0]) + "\t" +
formatCurrency(agent1Sales[1]) + "\t" + formatCurrency(agent1Sales[2]));
System.out.println(agent2.getName() + "\t" + formatCurrency(agent2Sales[0]) + "\t" +
formatCurrency(agent2Sales[1]) + "\t" + formatCurrency(agent2Sales[2]));

// Display the total property sales for each estate agent
System.out.println("\nThe total property sales for " + agent1.getName() + " = " + formatCurrency(agent1TotalSales));
System.out.println("The total property sales for " + agent2.getName() + " = " + formatCurrency(agent2TotalSales));

// Display the sales commission for each estate agent
System.out.println("\nSales commission for " + agent1.getName() + " = " + formatCurrency(agent1Commission));
System.out.println("Sales commission for " + agent2.getName() + " = " + formatCurrency(agent2Commission));

// Display the top performing estate agent
System.out.println("\nTop performing estate agent: " + (topAgent == 0 ? agent1.getName() : agent2.getName()));
}

public static String formatCurrency(double amount) {
return "R " + String.format("%,.2f", amount).replace(",", " ");
}
}
```

Finally, you can write the unit tests for the application using a testing framework like JUnit. Create a new test class named "EstateAgentTest" in a separate package. Here's an example of how the unit tests could be implemented:

```java
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class EstateAgentTest {

@Test
public void CalculateTotalSales_ReturnsTotalSales() {
double[] propertySales = {800000, 1500000, 2000000};
double expectedTotalSales = 4300000;

EstateAgent agent = new EstateAgent("Joe Bloggs", propertySales);
double actualTotalSales = agent.EstateAgentSales(propertySales);

assertEquals(expectedTotalSales, actualTotalSales, 0);
}

@Test
public void CalculateTotalCommission_ReturnsCommission() {
double propertySales = 4300000;
double expectedCommission = 86000;

EstateAgent agent = new EstateAgent("Joe Bloggs", new double[]{});
double actualCommission = agent.EstateAgentCommission(propertySales);

assertEquals(expectedCommission, actualCommission, 0);
}

@Test
public void TopAgent_ReturnsTopPosition() {
double[] totalSales = {4300000, 3500000};
int expectedTopAgent = 0;

EstateAgent agent = new EstateAgent("Joe Bloggs", new double[]{});
int actualTopAgent = agent.TopEstateAgent(totalSales);

assertEquals(expectedTopAgent, actualTopAgent);
}
}
```