Question
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:
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:
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.
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);
4. The output file should include the total units sold as the following:
InStock Jan FebMar Apr May Jun Name Acetaminophen 310 83 183 141 98 193 92 Mortrin 275 46 82 103 108 95 121Step 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