Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a C programming language Your task is to code in a C programming language to read in student names and grades from separate files,

In a C programming language

Your task is to code in a C programming language to read in student names and grades from separate files, and write a third file containing a summary of student grades as output of your programme. Below will also be a screenshot of all the data you will need, you can create your own csv file with the data I am going to provide in the screenshot

Details

Your program should read in a student or results CSV file, an activity CSV file, and output a third results CSV file containing a summary of the grades for each student. Your program should take three command line arguments: the filename of the student CSV file or a previously generated results CSV file, the filename of the activity CSV file, and the filename of the results CSV to write to respectively.

The first line of results CSV file should contain a header with the following format:

id,last_name,first_name,average,grade01,grade02,...

And then a line for each student (in the same order as they appear in the student CSV file) giving their ID, last name, first name, arithmetic mean of activity grades (to two decimal places), and the grades for each activity.

If your program is run with a student CSV file as its first argument, the results CSV file will just contain the following columns:

id,last_name,first_name,average,grade01

If your program is run with a results CSV file as its first argument, an extra column should be created listing the grades in the activity CSV file, and the average column updated to reflect the average grade across all previously recorded activities.

For example, if the following command is run:

$ ./task3 class01_students.csv class01_activity01.csv class01_results01.csv

The contents of theclass01_results01.csv file will be:

id,last_name,first_name,average,grade01

3444670,Hurrington,Sherri,30.00,30

3611390,Rich,William,0.00,0

2939734,Simmons,Erin,16.00,16

288301,Levi,Antonio,75.00,75

1295620,Henderson,Mabel,41.00,41

757790,Coffey,Paula,62.00,62

3149175,Green,Tom,56.00,56

3173019,Willis,Hazel,70.00,70

2890792,Osterberg,Marty,0.00,0

1274266,Winders,Nancy,90.00,90

Then, if the following command is run:

$ ./task3 class01_results01.csv class01_activity02.csv class01_results02.csv

The contents of theclass01_results02.csv file will be:

id,last_name,first_name,average,grade01,grade02

3444670,Hurrington,Sherri,37.00,30,44

3611390,Rich,William,0.00,0,0

2939734,Simmons,Erin,45.50,16,75

288301,Levi,Antonio,86.00,75,97

1295620,Henderson,Mabel,35.00,41,29

757790,Coffey,Paula,75.50,62,89

3149175,Green,Tom,59.00,56,62

3173019,Willis,Hazel,80.00,70,90

2890792,Osterberg,Marty,6.50,0,13

1274266,Winders,Nancy,62.00,90,34

You are free to choose whichever method you want to implement your program with the following restrictions:

  • your implementation must contain a correctly declaredmain function
  • you are not allowed to use global variables
  • all dynamically allocated memory should be freed
  • all user file handles should be closed

You can use any standard library functions (including those in the C maths library).

Your program will be tested against a number of randomly generated classes Your program will also be tested against a number of invalid cases e.g. an incorrect number of command line arguments, or incorrect numbers of columns in the student or activity CSV files. In these cases, an error message should be printed and your program should immediately exit with a non-zero exit code. All error messages in your implementation should be printed tostderr.

Your program should handle dynamically allocated memory correctly i.e. free all dynamically allocated memory. It should also make sure all user file handles are closed before it exits.

Data for the 2 activities

Class01_activity01.csv data below Class01_activity02.csv

image text in transcribedimage text in transcribedimage text in transcribed
id, grade 2939734, 16 3173019, 70 1274266, 90 3149175, 56 757790 62 288301, 75 1295620, 41 3444670, 30id, grade 2939734, 75 3173019, 90 1274266, 34 3149175, 62 2890792, 13 757790 89 288301, 97 1295620, 29 3444670, 44id, last name, first name 3444670, Hurrington, Sherri 3611390, Rich, William 2939734, Simmons, Erin 288301, Levi, Antonio 1295620, Henderson, Mabel 757790, Coffey, Paula 3149175, Green, Tom 3173019, Willis, Hazel 2890792, Osterberg, Marty 1274266, Winders, Nancy

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions