Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7.20 (Total Sales) Use a two-dimensional array to solve the following problem: A

ID: 3623739 • Letter: 7

Question

7.20 (Total Sales) Use a two-dimensional array to solve the following problem: A company has
four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each type of product sold. Each slip contains the following:
a) The salesperson number
b) The product number
c) The total dollar value of that product sold that day
Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that the information from all of the slips for last month is available. Write an application that will read all this information for last month’s sales and summarize the total sales by salesperson and by product. All totals should be stored in the two-dimensional array sales. After processing all the information for last month, display the results in tabular format, with each column representing a particular salesperson and each row representing a particular product. Cross-total each row to get the total sales of each product for last month. Cross-total each column to get the total sales by salesperson for last month. Your tabular output should include these cross-totals to the right of the totaled rows and to the bottom of the totaled columns.


we use netbeans in school so please make it netbeans friendly
please help me im drowning in this program

Explanation / Answer

please rate - thanks

import java.util.*;

public class TotalSales
{

public static void main(String args[])
{
double sales[][] = new double[4][5];
int i = 0, j = 0;
double total,grandtotal;
Scanner input = new Scanner(System.in);
for(i = 0; i < 4; i++)
{System.out.println("for salesman "+(i+1)+": ");

   for(j = 0; j < 5; j++)
    {System.out.print("Enter sales for item " + (j+1)+ ": ");
    sales[i][j] = input.nextDouble();
    }
System.out.println();
   
}

grandtotal=0;
System.out.println("     Salesman item 1 item 2 item 3 item 4 item 5 total");
for(i = 0; i < 4; i++)
   {System.out.print(" "+(i+1)+" ");
    total=0;
    for(j=0;j<5;j++)
       {total+=sales[i][j];
        System.out.print(sales[i][j]+" ");
        }
    System.out.println(total);
    grandtotal+=total;       
    }
System.out.print(" Total ");
for(i=0;i<5;i++)
   {total=0;
    for(j=0;j<4;j++)
        total+=sales[j][i];
    System.out.print(total+" ");
    }
System.out.println(grandtotal);
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote