I have a program that creates a double array for 50 states storing the last 10 tax rates for each year. The tax rate is less than .06 in all of them and is randomly configured to make the program run easier. This program is just to help me learn to access multidimensional arrays.

I need to create the following:

A method returning an array of indexes of the states that have had at least one year with a tax rate less than 0.001

I created a method that returns the max tax rate of all the states and years and also the least and returns the indexes.

However, I do not know how to return an array of indexes to satisfy this question.

Here's my class so far:

import java.text.DecimalFormat; public class SalesTax { private double [][] rates; public SalesTax() { rates = new double [50][10]; for(int x=0; x<rates.length; x++) { for(int i=0; i<rates[x].length; i++) { double z= Math.random(); while(z > .06) { z=Math.random(); } rates[x][i] = z; } } } DecimalFormat newForm = new DecimalFormat("0.000000"); public void get_largest_rate() { double max = rates[0][0]; int tmpI = 0; int tmpX = 0; for(int x = 0; x < rates.length; x++) { double[] inner = rates[x]; for (int i = 0; i < rates[x].length; i++) { if(inner[i] > max) { max = inner[i]; tmpX = x; tmpI = i; } } } System.out.println(newForm.format(max)); System.out.println("The index of the highest rate is: ("+tmpX+","+tmpI+")"); } public void get_less_tax() { double leastTax = rates[0][0]; int tmpX = 0; int tmpI = 0; for(int x = 0; x < rates.length; x++) { double[] inner = rates[x]; for (int i = 0; i < rates[x].length; i++) { if(inner[i] < leastTax) { leastTax = inner[i]; tmpX = x; tmpI = i; } } } System.out.println(newForm.format(leastTax)); System.out.println("The index of the lowest rate is: ("+tmpX+","+tmpI+")"); } }