Question
Overview The purpose of this assignment is to make sure that you know how to write a program that uses sorting and arrays. The program
Overview
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
named ASSGN6-B.txt, located in your assignment 6 repository on Brightspace. 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:
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 keep the related items (total count and cost) together. You can do
this however you choose. One idea considers creating parallel arrays, one for the item count
and one with the total cost. You could then process the arrays and compare the next item in
the sorted list with the prior item, etc., grouping all totals by items as you go.
The results should be displayed in the report. Your report should look as follows:
==============================================================
= FARMERS MARKET INVENTORY =
==============================================================
artichokes: 109 items totaling $243.07
beets: 111 items totaling $12.23
...
...
There were 999 items contributed to this weeks event.
Again, if you have multiple items then those records are combined, the total number of
items and respective costs, 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...
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 Brightspace. Note
functions and data validation are now required. Do not use
using namespace std;
ASSGN6-B.txt:
Collins Farm, 43900 tomatoes 0.67 29413 Bart Smith Farms, 34910 cassavas 0.99 34560.9 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.5 187.5 Weaver Farms, 500 pickles 0.59 295 Pore Boy Farms, 670000 peanuts 0.79 529300 Rutherford Farms Inc., 809 apples 0.9 728.1 Rutherford Farms Inc., 659 pickles 0.7 461.3 Javens Farm, 129000 figs 0.44 56760 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
Field or data item in the file Farm name Count of item Item Item price Total price Data type Notes String of characters This could end with a comma Integer String Float or double Float or double Number of item:s Name of the item Unit cost of each item The unit cost * count of items Field or data item in the file Farm name Count of item Item Item price Total price Data type Notes String of characters This could end with a comma Integer String Float or double Float or double Number of item:s Name of the item Unit cost of each item The unit cost * count of items
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started