Question: JAVA Use a two-dimensional array to solve the following application problem: A company has four salespeople (1 to 4) who sell five different products (1
JAVA
Use a two-dimensional array to solve the following application problem: A company has four salespeople (1 to 4) who sell five different products (1 to 5). The data file hw2data.txt contains all salespeoples sales information for five products for last month. Each row represents a particular product and each column represents a salesperson. Write an application that will read all this information from the file, display the raw data on the screen, process the data, and summarize the following information:
1) The total sales by product. 2) The total sales by salesperson. 3) The highest sales by product. 4) The highest sales by salesperson. 5) The total sales by all salesperson for last month.
After processing all the information, display the results in a neat tabular format, with each column representing a salesperson and each row representing a particular product. Display the total sales by product and the highest sales by product to the right of the rows and display the total sales by salesperson and the highest sales by salesperson to the bottom of the columns.
You must write the following six methods and call them in Task 2.
-
printArray. This method should accept a two-dimensional array as its argument and display the
contents of the array on the screen. The header of the method is:
public static void printArray(double[][] array)
-
getTotal. This method should accept a two-dimensional array as its argument and return the
total of all the values in the array. The header of the method is:
public static double getTotal(double[][] array)
-
getRowTotal. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument is the subscript of a row in the array. The method should return the total of the values in the specified row of the array. The header of the method is: public static double getRowTotal(double[][] array, int row)
-
getColumnTotal. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument is the subscript of a column in the array. The method should return the total of the values in the specified column. The header of the method is:
public static double getColumnTotal(double[][] array, int col)
-
getHighestInRow. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument is the subscript of a row in the array. The method should return the highest value in the specified row of the array.
-
getHighestInColumn. This method should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument is the subscript of a column in the array. The method should return the highest value in the specified column of the array.
Consider using 4 double arrays to store total sales for each person, total sales for each product, the highest sales for each person, and the highest sales for each product.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
