Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[C++] Language. The purpose of this assignment is to make sure that you know how to write a program that uses sorting and arrays. The

[C++] Language.

The purpose of this assignment is to make sure that you know how to write a program that uses sorting and arrays. The program also contains functions and may perform input, output, files and file processing, flow of control, and/or calculations.Please note that this assignment indicates precisely what your program should accomplish, without a precise indication of how the program works. Part of your assignment is designing the techniques of how the program works.

PROGRAM SPECIFICATION

For the assignment, we will read the updated file of information about the Farmers Market that you created in Assignment6-A. Recall that the file contains the names of various farms participating in a Farmers Market. The created output from your previous assignment should have rewritten the information in this format:

Field or data item in the file

Data type

Notes

Farm name

String of characters

This could end with a comma

Count of item

Integer

Number of items

Item

String

Name of the item

Item price

Float or double

Unit cost of each item

Total price

Float or double

The unit cost * count of items

Reminder that when reading the information into your program, the space between each field should have remained consistent and guaranteed. Also, we will not need to validate the information in this program.

Your program will read the file and report on each items total contribution to the Farmers Market. So if there are 2 like items (i.e., there are 2 records for that item), you will add each contribution in running totals and report that. If theres only one thats easy, its just that one as the total.

Since the file is sequentially ordered by the farm names, we will need to perform a sorting operation. We will need to sort by the item name so we can group and compare. You will need to write a selection sort and sort the file as an array. You will use the item as the sort value/key. You will need to read the file and place the name of the items into an array (you only need the items), then perform a selection sort on the array, and then read the sorted array and count up the number of times each item appears. As you read the sorted array, the results should be displayed in a report.

Your report should look as follows:

==============================================================

= FARMERS MARKET INVENTORY =

==============================================================

2 loads of artichokes were delivered

3 loads of beets were delivered

There were 999 items contributed to this weeks event.

Again, if you have multiple items then those records are combined as the total number of items, and only one entry then appears for that particular farm. Add the total number of items to display at end. If there are 3 beets, for example, that would only add 1 to the count (for beets), etc note that the above is representative of the format, not the actual data.

Hint: Youre going to want to save the previous items name, and then compare that to the one you are reading. Use the string compare operator for equality (such as stringName1 != stringName2). Make sure that your timing is right when printing.

Make sure you break your code into functions. Open your files in main and pass them by reference.

Make sure that your programs follow good documentation standards and follow the requirements for assignments. Reference the rubric standards on Springboard. Note functions and data validation are now required. Do not use using namespace std;.

FILE TO BE INPUT IS AS FOLLOWS:

========================================================================= = Farmer's Market Inventory = ========================================================================= Collins Farm, 43900 tomatoes 0.67 29413.00 Bart Smith Farms, 34910 cassavas 0.99 34560.90 Allen Farms, 117 coconuts 0.54 63.18 River Run Farm, 103 taros 0.65 66.95 Big Top Farm, 109 artichokes 2.23 243.07 Big Top Farm, 777 crosns 0.28 217.56 Big Top Farm, 9739 cucumbers 0.53 5161.67 Marble Farm, 108 crosns 0.33 35.64 Food For Life Inc., 106 carrots 0.87 92.22 Food For Life Inc., 86 coconuts 0.84 72.24 Johnson Farms, 121 parsnips 0.22 26.62 A1 Farm, 111 beets 0.12 13.32 A1 Farm, 5591 taros 0.72 4025.52 Looney Tunes Farm, 102 onions 0.49 49.98 Wolfe Creek Farm, 103 rhubarbs 1.21 124.63 Wolfe Creek Farm, 199 radishes 0.71 141.29 James Farm, 47 pickles 0.68 31.96 Weaver Farms, 75 walnuts 2.50 187.50 Weaver Farms, 500 pickles 0.59 295.00 Pore Boy Farms, 670000 peanuts 0.79 529300.00 Rutherford Farms Inc., 809 apples 0.90 728.10 Rutherford Farms Inc., 659 pickles 0.70 461.30 Javens Farm, 129000 figs 0.44 56760.00 Harrison Farms, 8001 yams 1.09 8721.09 Setzer Farms Inc., 701 potatoes 0.89 623.89 Setzer Farms Inc., 651 tomatoes 0.69 449.19 Pikes Peak Farm, 1045 turnips 0.79 825.55 Holland Area Farms, 10001 radishes 0.69 6900.69 Grand Total: 917671 items totaling $ 679592.06

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions