Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider some data gathered in a file for general pain medicine and allergy medicine for a local drugstore in a small town for a six

Consider some data gathered in a file for general pain medicine and allergy medicine for a local drugstore in a small town for a six month period:

image text in transcribed

The numbers represents the number of units in stock at the drugstore, and units sold for the six months starting January. The file has the following format:

image text in transcribed

Write a C program that can read in the data from a file and sort the medicine by total units sold for the six month period. The sorted data should be written the same file name as the input file name with added extension of .srt. For example, if the original file name is pain_allergy.txt, the output file name is then pain_allergy.txt.srt. Pain_allergy.txt is found below.

image text in transcribed

1. Define a structure medicine to store the name (string), unitsInStock (integer), and six months unitsSold as an array of int, and total units sold (int). Assume the name is no more than 100 characters. Assume the name is one word name.

2. Build an array of medicine structures. Assume that there are no more than 100 medicines.

3. Modify the selection_sort function found just below to sort an array of medicines. The medicines should be sorted by total units sold. The function should have the following prototype:

void selection_sort(struct medicine meds[], int n);

image text in transcribed

4. The output file should include the total units sold as the following:

image text in transcribed

InStock Jan FebMar Apr May Jun Name Acetaminophen 310 83 183 141 98 193 92 Mortrin 275 46 82 103 108 95 121

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

Discuss the relationship between a manager and an HR professional.

Answered: 1 week ago

Question

what is a peer Group? Importance?

Answered: 1 week ago