Use a two-dimensional (double-subscripted) array to solve the following problem: A company has four salespeople who sell five different products. Let each salesperson represent a row of your array and each product a column. You now have a 4 x 5 array. Once a day, each salesperson submits a slip for each different type of product he or she sold. Each slip contains: The salesperson’s number (1 to 4) (use this to get row subscript) The product number (1 to 5) (use this to get column subscript) The total dollar value of that product sold that day Thus, each salesperson submits from 0 to 5 sales slips per day (0, if they made no sales that day; and 5, if they sold every product that day). Your program will read a file that contains the information from all of the sales slips for the last month. Read until EOF. The file is named "productSales.txt". You need to create this file with at least 10 entries. Remember that the first number is the salesperson, the second number is the product, and the third number is the amount of sales. The entries can be in any order. Here is an example of part of the file: * The picture has been inserted as the first one*       The program will calculate the total sales of each product by each salesperson. All totals should be stored in the two-dimensional (double-scripted) array sales. After processing all the information for the month, print the results in tabular format with each row representing a salesperson and each column representing a particular product. Total each row to get the total sales of each salesperson for the last month; total each column to get the total sales of each product for the last month. Print the total sales for each salesperson to the right of the other columns and print the total sales for each product below the other rows. Your program should also calculate and display the number of the salesperson who made the most sales for the entire month, the number of the product which earned the company the least amount of money for the month, and the number of the product which earned the company the most amount of money for the month.   *The picture has been inserted as the second one* Your program should include the following methods: main() readSales() - read the sales slips from "sales.txt" and add them to the appropriate element in the sales array. displaySales() - print the results in tabular format including the totals for each salesperson and each product. Use printf to make the output line up nicely. greatest_person() - compute and print the number of the salesperson who sold the most. least_product() - compute and print the number of the product which earned the least amount of money. greatest_product() - compute and print the number of the product which earned the most amount of money

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

2. Use a two-dimensional (double-subscripted) array to solve the following problem:

A company has four salespeople who sell five different products. Let each salesperson represent a row of your array and each product a column. You now have a 4 x 5 array. Once a day, each salesperson submits a slip for each different type of product he or she sold. Each slip contains:

  1. The salesperson’s number (1 to 4) (use this to get row subscript)
  2. The product number (1 to 5) (use this to get column subscript)
  3. The total dollar value of that product sold that day

Thus, each salesperson submits from 0 to 5 sales slips per day (0, if they made no sales that day; and 5, if they sold every product that day).

Your program will read a file that contains the information from all of the sales slips for the last month. Read until EOF. The file is named "productSales.txt". You need to create this file with at least 10 entries. Remember that the first number is the salesperson, the second number is the product, and the third number is the amount of sales. The entries can be in any order. Here is an example of part of the file:

* The picture has been inserted as the first one*

 

 

 

The program will calculate the total sales of each product by each salesperson. All totals should be stored in the two-dimensional (double-scripted) array sales. After processing all the information for the month, print the results in tabular format with each row representing a salesperson and each column representing a particular product. Total each row to get the total sales of each salesperson for the last month; total each column to get the total sales of each product for the last month. Print the total sales for each salesperson to the right of the other columns and print the total sales for each product below the other rows.

Your program should also calculate and display the number of the salesperson who made the most sales for the entire month, the number of the product which earned the company the least amount of money for the month, and the number of the product which earned the company the most amount of money for the month.

 

*The picture has been inserted as the second one*

Your program should include the following methods:

  • main()
  • readSales() - read the sales slips from "sales.txt" and add them to the appropriate element in the sales array.
  • displaySales() - print the results in tabular format including the totals for each salesperson and each product. Use printf to make the output line up nicely.
  • greatest_person() - compute and print the number of the salesperson who sold the most.
  • least_product() - compute and print the number of the product which earned the least amount of money.
  • greatest_product() - compute and print the number of the product which earned the most amount of money.
This is a Java program. 
 
 
 
is the amount of sales. The entries can be in any order. Here is an example of part of the file:
1 5 202.00
3 4 749.99
1 2 300.00
2 1 320.00
1 5 325.50
Transcribed Image Text:is the amount of sales. The entries can be in any order. Here is an example of part of the file: 1 5 202.00 3 4 749.99 1 2 300.00 2 1 320.00 1 5 325.50
Here is an example of the output format:
Person Prod1 Prod2 Prod 3
1
100.00 200.00 300.00
200.00 400.00 200.00
2
etc.
Prod 4
Prod 5
400.00
300.00
400.00 200.00
Total: 800.00 900.00 600.00 1500.00 750.00
Most Sales: Person 2
Most Earning: Product 4
Least Earning: Product 3
Total
1300.00
1400.00
Transcribed Image Text:Here is an example of the output format: Person Prod1 Prod2 Prod 3 1 100.00 200.00 300.00 200.00 400.00 200.00 2 etc. Prod 4 Prod 5 400.00 300.00 400.00 200.00 Total: 800.00 900.00 600.00 1500.00 750.00 Most Sales: Person 2 Most Earning: Product 4 Least Earning: Product 3 Total 1300.00 1400.00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning