Question: Write a C + + program that reads sales data from a file called sales.txt . Each line of the file contains four data items;

Write a C++ program that reads sales data from a file called sales.txt. Each line of the file
contains four data items;
1. A product number which is an integer
2. A product name which is a string no longer than 12 characters and which does not
contain spaces
3. A unit price which is a double
4. A number of units sold which is an integer
The program will output the two products which generated the highest total revenue (unit
price * number sold).
Your program must:
1. Read each line of the file storing the four items into the members of a
dynamically allocated structure.
2. Store pointers to the structures in an array.
3. Sort the array of pointers by total revenue
4. Display the product name and total revenue of the top two products
5. The program must work for sales.txt files with anywhere from 2 to 100 products
 Write a C++ program that reads sales data from a file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!