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
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:
- 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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images