Question: myrecord_main.c: #include #include #include #include #include myrecord.h #define MAX_REC 100 int main(int argc, char *args[]) { char infilename[40] = marks.txt; //default input file name char

![main(int argc, char *args[]) { char infilename[40] = "marks.txt"; //default input file](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3083d1ee29_38866f3083c9bb39.jpg)
![name char outfilename[40] = "record_report.txt"; //default output file name if (argc >](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3083de93c8_38966f3083d8946d.jpg)
myrecord_main.c:
#include
#include
#include
#include
#include "myrecord.h"
#define MAX_REC 100
int main(int argc, char *args[]) {
char infilename[40] = "marks.txt"; //default input file name
char outfilename[40] = "record_report.txt"; //default output file name
if (argc > 1) {
if (argc >= 2) strcpy(infilename, args[1]);
if (argc >= 3) strcpy(outfilename, args[2]);
}
RECORD dataset[MAX_REC]; // declare array of RECORD to store record data
int record_count = import_data(infilename, dataset);
if (record_count >=1) {
STATS stats = process_data(dataset, record_count);
printf("stats:value ");
printf("count:%d ", stats.count);
printf("mean:%.1f ", stats.mean);
printf("stddev:%.1f ", stats.stddev);
printf("median:%.1f ", stats.median);
printf(" name:score,grade ");
int i;
for (i = 0; i
printf("%s:%.1f,%c ", dataset[i].name, dataset[i].score, letter_grade(dataset[i].score));
}
report_data(outfilename, dataset, stats);
} else
printf("no record");
return 0;
}
myrecord.h:
#ifndef MYRECORD_H #define MYRECORD_H typedef struct { char name[40]; float score; } RECORD; typedef struct { int count; float mean; float stddev; float median; } STATS; char letter_grade(float score); int import_data(char *infilename, RECORD *records); STATS process_data(RECORD *records, int count); int report_data(char *outfilename, RECORD *records, STATS stats); #endifmyrecord.c:
#include#include #include #include #include "mysort.h" #include "myrecord.h" #define MAX_LINE 100 char letter_grade(float s){ // your implementation } STATS process_data(RECORD *dataset, int n) { // your implementation } int import_data(char *infilename, RECORD *records) { // your implementation } int report_data(char *outfilename, RECORD *records, STATS stats) { // your implementation }
marks.txt:
Myrie,76.7 Hatch,66.5 Costa,45.1 Dabu,74.4 Sun,67.7 Chabot,80.4 Giblett,59.1 Suglio,85.7 Smith,60.1 Bodnar,93.6 Allison,67.7 Koreck,77.4 Parr,92.5 Lamont,98.1 Peters,82.3 Wang,98.1 Eccles,77.8 Pereira,80.3 He,85.7 Ali,88.0
record_report.txt:
stats:value count:20 mean:77.9 stddev:13.5 median:79.1 name,score,grade Myrie,76.7,B Hatch,66.5,C Costa,45.1,F Dabu,74.4,B Sun,67.7,C Chabot,80.4,A Giblett,59.1,D Suglio,85.7,A Smith,60.1,C Bodnar,93.6,S Allison,67.7,C Koreck,77.4,B Parr,92.5,S Lamont,98.1,S Peters,82.3,A Wang,98.1,S Eccles,77.8,B Pereira,80.3,A He,85.7,A Ali,88.0,A
Write C programs myrecord.h and myrecord.c to load record data from a mark data file, process the data by computing simple statistics, and then report the processed information. The mark records are given by comma-separated values (CSV) format in file marks.txt. Processing the mark data is to compute the record count, the average, standard deviation, median of the mark score values, and letter grades. Reporting is to output results to a file like record report.txt. It requires to use a sorting function of Q1 of your choice to compute the median. Specifically, myrecord.h contains the structure and function specs as follows, myrecord.c contains the implementation of the functions. Define a structure named RECORD to hold a person's name of 20 characters and the score of float type. */ /* Define a structure named STATS containing fields int count, float mean, float stddev (standard deviation), and float median. */ /* This function converts a float score to a letter grade according to ranges S=[90,100],A= [80,90),B=[70,80),C=[60,70),D=[50,60),F=[0,50), and returns the letter grade. */ char letter_grade(float score); / This function imports record data from file of name passed by infilename, and retrieves and stores all record entries in the RECORD array passed by records, and returns the number of record count. */ int import_data(char *infilename, RECORD *records); /* This function takes the RECORD array passed by records and the number of record count as input, computes the average score, standard deviation, median of the score values of the record data, and returns the results in STATS type. */ STATS process_data(RECORD *records, int count); /* This function takes output file name passed by outfilename, RECORD array passed by records, and STATS value passed by stats, and output stats information, and processed record data to files in required format. It returns if all operations are successful, otherwise . */ int report_data(char *outfilename, RECORD *records, STATS stats); Use the provided test program myrecord main.c to test your myrecord.c the screen output is like the following, and the output file is like record report.txt. command: gcc mysort.c myrecord.c myrecord_main.c -o myrecord command: myrecord stats:value count:20 mean:77.9 stddev:13.5 median:79.1 name:score,grade Myrie:76.7, B Hatch: 66.5,C Costa:45.1,F Dabu:74.4,B Sun: 67.7,C Chabot: 80.4,A Giblett:59.1,D Suglio:85.7,A Smith: 60.1,C Bodnar:93.6, S Allison:67.7, C Koreck:77.4,B Parr: 92.5,S Lamont:98.1, S Peters:82.3,A Wang: 98.1,S Eccles:77.8, B Pereira:80.3, A He:85.7, A Ali: 88.0,A
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
