Displaying my 2D array code
<p>Requirements:</p>

<p>1.How to display the stored data for each individual month without having to copy and paste code several times for the DisplayMonthData() method?</p>

<p>2.Is my code for summing up all the values for each month correct in DisplayMonthData()?</p>

<p>Thanks in advance.</p>

<pre><code>      static void MonthData()
  {            
    try{
    for(int i=0;i&lt;10;i++){
    System.out.print("Enter item "+(i+1)+" &lt;Press ENTER to exit&gt; : ");
    monthItems[m][i] = input.next();
        if (monthItems[m][i].length() == 0){
            return;
        } else {
        System.out.print("Enter amount : $");
        amount[m][i] = input.nextDouble();
        System.out.println("");
        }   
    }
    }catch(Exception e){
        System.out.println("");
    }   
    }
  static void DisplayMonthData()
  {
    if(months[m]=="Jan"){
    for(int row=1;row&lt;amount.length;row++){
        for(int column=0;column&lt;amount[row].length;column++){
            //janItems[]+=monthItems[1][0];
            if(amount[row][column]!=0){
             System.out.println(monthItems[row][column]+"\t$"+fmt.format(amount[row][column]));
            }else{}
        }
    }
        sum[L]+=amount[1][0];
        System.out.println();
        System.out.println("Total amount spent for the month of January is $"+fmt.format(sum[L]));
        L++;
        }
  }
</code></pre>
