Programming Homework Help

Programming Homework Help. Java Passing User input into array

I want to take the user data thats inputted and put into an array.

I wish there was a way for me to upload the files.

class PetrolStation
{

public static void main(String[] arg)

{
  String [] COUNTIES = {“Broward”, “Miami-Dade”, “Palm Beach”, “Average”};
   String [] PETROL_TYPE = {“Regular”, “Plus-2”, “Supreme”, “Diesel”, “Average”};
   double petrol_price[][] = new double[PETROL_TYPE.length][COUNTIES.length];
   load(petrol_price, COUNTIES, PETROL_TYPE);
   PetrolPrice s = new PetrolPrice(petrol_price, COUNTIES, PETROL_TYPE);
  System.out.println(“n…. Price for each type of petrol per county…..”);
   s.display();

}

   static void load(double price[][], String COUNTY[], String[] TYPE) {
//    Complete the definition for reading the data and storing them in the array called price
   
   for (int i = 0; i < price.length – 1; i++)
   {
   String s =  TYPE[i]; //Extract petrol type to prompt user
   for (int j = 0; j < price[i].length – 1; j++)
   {
   String t = COUNTY[j];  // Extract county to prompt user
   price[i][j] = GetData.getDouble(t + ” n”+ s);
   }
   }

}
}

————-

public class PetrolPrice
{
  double petrol_price[][];
  String PETROL_TYPE[];
  String COUNTIES[];
   
  String s;
   
  //constructor
  PetrolPrice(double price[][], String county[], String type[])
  {
  petrol_price = price;
  COUNTIES = county;
  PETROL_TYPE = type;
   
  s = “”;
  }

   
  //method to display prices
  public void display(double price[][],String county[],String type[])
  {
  for(int row = 0; row < price.length; row++)
  {
  for(int column = 0; column < price[row].length; column++)
  {
  System.out.println();
  System.out.println(price[row][column]+ “t”);
//  s = s + petrol_price[row][column]+ “t”;
  }
  System.out.println();
  }
//  return s;
  }
}
   
//  //method to average the three counties – columns
//  public double column_averages()
//  {
//  double sum = 0;
//   
//  for(int i = 0; i < price.length; i++)
//  {}
//  }
//   
//  //method to average the four gas types – rows
//  public double row_averages()
//   
//  {
//  double sum = 0;
//   
//  for (int i = 0;  i < price.length; i++)
//  {
//  double num = price[i];
//  sum = sum + num;
//  }
//   
//  return sum / (price.length);
//   
//  }
//   
//  //
//}

Programming Homework Help

 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"