Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm using electronics as my category. Please write a C++ program. I also provided you with a sample code CSC240 - Lab Assignment #3 Arrays

I'm using electronics as my category. Please write a C++ program. I also provided you with a sample code image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
CSC240 - Lab Assignment \#3 Arrays and Methods Assigned: Week 4 Due: Week 5 Points: 50 Choose a type of product to sell (food, apparel, electronics, cosmetics, housewares, etc.). Create a program which loads 4 parallel arrays with 20 items each. Use your own data. Do not replicate data which I post, nor use data from another student. Make at least. 4 categories, for example, if you were categorizing animals, then you would use M for mammal, R for reptile, F for fish, and B for bird. Store the following 4 parallel arrays in main(). Populate them with data using initializer lists. - string [l productName - double [] productPrice - int I] productQuantity - char [] productCategory Requirements: Store your data in parallel arrays: Create the following functions: 1. void displayReport(string pn[1, double ppil, int pq[l]. char pe(I) which will have a report format with headers, detail line and footers as follows (note that widths are suggested with cout manipulators): Product (setw(20)) Price (setw(10)) Qty ( setw(10)) Category(setw(10))Ext. Price (setw(10)) xococoxouxoxoxoxoxox 9999999.999999999999 xxocoxoxx 9999999.99 Average Sales: 9999999.99 (INOTE: This is generated by findTotalSales ) Total Sales: 9999999.99 (I NOTE: This is generated by findAverage5alesi) 2. double findtotalsales (double ppli, int pq[D 2. double findAveragesales(double ppll, int pq(l) 3. double findAveragesales(double ppil. inf pqin productid productDetailline0, productheader), and productfooterd functions to generate parts of the reports. 5. void changequantityl - search for a product and change the quantity for that product in the arrayThis will require that the user enter a value (use Scanner here), then search, and enter another value to replace that with. 6. vaid changeprice() - search for a product and change the price for that product in the array. Similar input to 15. 7. void categoryReportichar c) - send any category to this function to generate a report 1. void categoryReportichar c) - send any category to this function to generate a report below the max 9. vold sortByNameReportistring pn(l, double ppll, int pqili - uses a bubble sort and an index sarting algorithm 10. void sort fypriceReporto) - similar to 49 Use a menu which will allow you to do the foliowing with the data (Have this loop with a sentinel to Use a menu which wiil ailow you to do the fali 1. Display Report of data in original order with header and footer equirements: Store your dota in parallel arrays: Create the following functions: 1. void displayReport(string pn[], double pp[l, int pq[l, char pc[]) which will have a report format with headers, detail line and footers as follows (note that widths are suggested with cout manipulators): Product ( setw(20)) Price ( setw (10))Qty(setw(10)) Category(setw(10)) Ext. Price (setw(10)) Average Sales: 9999999.99 (I NOTE: This is generated by findTotalSales() Total Sales: 9999999.99 II NOTE: This is generated by findAverageSales0 2. double findTotalSales(double pp[1, int pq[]) 3. double findAverageSales(double pp[l, int pq[l]) 4. void productDetailine(), productheader(), and productiooter() functions to generate parts of the reports. 5. void changeQuantity() - search for a product and change the quantity for that product in the array. This will require that the user enter a value (use Scanner here), then search, and enter another value to replace that with. 6. void changePrice() - search for a product and change the price for that product in the array. Similar input to 15. 7. void categoryReport(char c) - send any category to this function to generate a report 8. vold priceReport(double p) - send a max price to this function to generate a report for products below the max 9. void sortbyNameReport(string pn[1, double pp[l, int pq[1) - uses a bubble sort and an index sorting algorithm 10. void sortByPriceReport() - similar to 99 Use a menu which will allow you to do the following with the dats (Have this loop with a sentinel to continue or stop as the last menu item or o): 1. Display Report of data in original order with header and footer 2. Display Report of data in original order based on a category (fitten) 3. Change Record (one or more fields of your choice) 4. Sort by Name and show report 5. Sort by Price (or some other field of your choice) and show report Outputs show all reporting function output including displayReport0. priceReport(). categoryReport() and sortiyNamefeport(), sortBypriceReport(). Provide source code and output samples zipped up and posted to the assignment link. include kiostreatp Minclude cionanips Ainclude kstring? using nanespace std; void displayReport(string pn[1, double pp[1, int pq[], char pc[]) 1. 3 void printpriceArray(double array[]) f for ( int 1=;1 to array[1+1]){ If swapping elements if elenents II are not in the intended order double tenp e array[i]: array [1]=array[1+1]; array [1]+1]= tempi yoid bubblesortindexed(doubte array[], int size, int index[]) f If loop to access each array element. for (int step = ej step \& sixe; itstep) ( If loop to compare array elements for (1nt 1=0;1 to arraylindexting [1]1) ( if swapging eteeents if eteeentu If are not in the intended order iat tees : index [1]. int teme * index 11] index 111 indexit 13 index [1]+1] indexit tepi Int nain() \& "A","B",BCn,"Dn,=E","A.","B*","C","o*","E"? double productprice[ ]= 1.e,2.,3.0,4.,5.,1.0,2.,3.6,4.0,5.0,1.,2.0,3.0,4.8,5.1.0,2.0,3.0,4.0,5.0} Int productquantity[] ={1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5)3: char productcategory[] = cout e "originatiln"' printpricenrray (productprico); cout e endi; bubblesort (productprice, 20); cout e "sortedthn": printpriceArray (productPrice); ceot endt: int index[2e]) index [1]=17 bubblesortindexed(preductprice, 20 , index); disp taypeport (productkane, groductprice, preductquantity, preductcatogory); ) return it

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Describe How to Develop and Communicoie o Vision.

Answered: 1 week ago

Question

a. Does your organization have a compliance and ethics office?

Answered: 1 week ago