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:
Q.1.1 Contain a two-dimensional array to contain three property sales for January, February,
and March for two different estate agents.
ESTATE AGENTS 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
Q.1.2 Calculate and print the total property sales for each estate agent.
Q.1.3 Calculate and print the total 2% commission earned by each estate agent.Q.1.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);
}
Q.1.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 Test Purpose
CalculateTotalSales_ReturnsTotalSales() 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.
CalculateTotalCommission_ReturnsCommission() 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.
TopAgent_ReturnsTopPosition() 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

Here is the Java application that meets the given requirements:

```java
import java.util.Arrays;

public class EstateAgent implements IEstateAgent {

// Two-dimensional array to store three property sales for January, February, and March
private double[][] propertySales;

// Constructor to initialize the property sales array
public EstateAgent() {
propertySales = new double[][] {
{800000, 1500000, 2000000},
{700000, 1200000, 1600000}
};
}

// Calculates the total property sales for each estate agent
public double[] EstateAgentSales() {
double[] totalSales = new double[propertySales.length];

for (int i = 0; i < propertySales.length; i++) {
for (int j = 0; j < propertySales[i].length; j++) {
totalSales[i] += propertySales[i][j];
}
}

return totalSales;
}

// Calculates the 2% commission earned by each estate agent
public double[] EstateAgentCommission() {
double[] totalSales = EstateAgentSales();
double[] commission = new double[totalSales.length];

for (int i = 0; i < totalSales.length; i++) {
commission[i] = totalSales[i] * 0.02;
}

return commission;
}

// Finds the top-selling estate agent
public int TopEstateAgent() {
double[] totalSales = EstateAgentSales();
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;
}

// Test method to display the results
public void displayResults() {
double[] totalSales = EstateAgentSales();
double[] commission = EstateAgentCommission();
int topAgent = TopEstateAgent();

System.out.println("ESTATE AGENTS\tJAN\tFEB\tMAR");
System.out.println("Joe Bloggs\tR " + propertySales[0][0] + "\tR " + propertySales[0][1] + "\tR " + propertySales[0][2]);
System.out.println("Jane Doe\tR " + propertySales[1][0] + "\tR " + propertySales[1][1] + "\tR " + propertySales[1][2]);

System.out.println("\nTotal property sales by estate agent:");
System.out.println("Joe Bloggs: R " + totalSales[0]);
System.out.println("Jane Doe: R " + totalSales[1]);

System.out.println("\n2% commission earned by estate agent:");
System.out.println("Joe Bloggs: R " + commission[0]);
System.out.println("Jane Doe: R " + commission[1]);

System.out.println("\nTop selling estate agent: " + (topAgent == 0 ? "Joe Bloggs" : "Jane Doe"));
}

public static void main(String[] args) {
EstateAgent estateAgent = new EstateAgent();
estateAgent.displayResults();
}

}

interface IEstateAgent {
double[] EstateAgentSales();
double[] EstateAgentCommission();
int TopEstateAgent();
}
```

And here is the test class in the separate package for the unit tests:

```java
package tests;

import org.junit.Assert;
import org.junit.Test;

import estateagent.EstateAgent;

public class EstateAgentTest {

@Test
public void CalculateTotalSales_ReturnsTotalSales() {
EstateAgent estateAgent = new EstateAgent();
double[] expectedTotalSales = {4300000, 3500000};
double[] totalSales = estateAgent.EstateAgentSales();

Assert.assertArrayEquals(expectedTotalSales, totalSales, 0);
}

@Test
public void CalculateTotalCommission_ReturnsCommission() {
EstateAgent estateAgent = new EstateAgent();
double[] expectedCommission = {86000, 70000};
double[] commission = estateAgent.EstateAgentCommission();

Assert.assertArrayEquals(expectedCommission, commission, 0);
}

@Test
public void TopAgent_ReturnsTopPosition() {
EstateAgent estateAgent = new EstateAgent();
int expectedTopAgent = 0;
int topAgent = estateAgent.TopEstateAgent();

Assert.assertEquals(expectedTopAgent, topAgent);
}

}
```

To run the unit tests, you can use a testing framework like JUnit.