Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

saw related versions of this on here. Make sure pointers are used, and the correct information is calculated and presented. Thanks! 1002 Hammer 23.65 203

image text in transcribedimage text in transcribed

saw related versions of this on here. Make sure pointers are used, and the correct information is calculated and presented. Thanks!

1002 Hammer 23.65 203 1024 Nails 6.95 400 1276 Screwdriver 13.95 251 1385 Elec_Drill 45.69 132 1462 Air_Filter 7.95 500 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 Hints: Chapter 8 describes the bubble sort and selection sort. You may use which ever you choose. Note that you will need to modify the code to sort the pointers based on the total revenue. Using functions is not required for this assignment, but consider using functions to read the file and to sort the data. A sample data file is attached to this assignment. The correct output for this file is below. Note that I will test your programs with a different file with a different number of products. The top selling product is Elec_Drill with total sales of $6031.08 The second top selling product is Hammer with total sales of $4800.95

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

6. Conduct a cost-benefit analysis for a training program.

Answered: 1 week ago