Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would like to have this in c++ with comments please.Thank you. Overview The purpose of this assignment is to make sure that you know

I would like to have this in c++ with comments please.Thank you.

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 Springboard. 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 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.

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.

. Note functions and data validation are now required. Do not use using namespace std;.

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago