Here is a Java program that fulfills the requirements mentioned above:
```java
public class EstateAgentSales {
public static void main(String[] args) {
// Two-dimensional array to store property sales for two estate agents
int[][] propertySales = {
{800000, 1500000, 2000000},
{700000, 1200000, 1600000}
};
// Estate agent names
String[] estateAgentNames = {"Joe Bloggs", "Jane Doe"};
// Calculate and print total property sales for each estate agent
System.out.println("Total Property Sales:");
for (int i = 0; i < estateAgentNames.length; i++) {
int totalSales = 0;
for (int j = 0; j < propertySales[i].length; j++) {
totalSales += propertySales[i][j];
}
System.out.println(estateAgentNames[i] + ": R " + totalSales);
}
// Calculate and print total 2% commission earned by each estate agent
System.out.println("\nTotal 2% Commission:");
for (int i = 0; i < estateAgentNames.length; i++) {
double totalCommission = 0;
for (int j = 0; j < propertySales[i].length; j++) {
totalCommission += propertySales[i][j] * 0.02;
}
System.out.println(estateAgentNames[i] + ": R " + totalCommission);
}
// Determine and print the top-selling estate agent
int topAgentIndex = 0;
int topAgentSales = 0;
for (int i = 0; i < estateAgentNames.length; i++) {
int totalSales = 0;
for (int j = 0; j < propertySales[i].length; j++) {
totalSales += propertySales[i][j];
}
if (totalSales > topAgentSales) {
topAgentSales = totalSales;
topAgentIndex = i;
}
}
System.out.println("\nTop-Selling Estate Agent: " + estateAgentNames[topAgentIndex]);
}
}
```
This program uses a two-dimensional array `propertySales` to store the property sales for each estate agent for January, February, and March. The estate agent names are stored in the `estateAgentNames` array.
The program then calculates and prints the total property sales for each estate agent by iterating through the `propertySales` array and adding up the sales for each month. It also calculates and prints the total 2% commission earned by each estate agent by multiplying each property sale by 0.02.
Finally, the program determines and prints the top-selling estate agent by finding the estate agent with the highest total property sales.
Note that the program assumes that the input data is correct and follows the specified format.
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.
1 answer