Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Using C programming language

your task is to code in a C programming language to read in student names and grades from separate files, and print out the students names and grades. A Screen shot will be provided below this task which will have the student names, their grades, ID number and all the data you will need. You can create your own CSV file using the information in the screenshot

Details

Your program should read in a student CSV file and an activity CSV file and output the student first name, last name and grade in the format specified below.

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 should take two command line arguments: the filename of the student CSV file and filename of the activity CSV file respectively. It should output the student first name, last name and grade. For example:

$ ./task2 class01_students.csv class01_activity01.csv

Sherri Hurrington 30

William Rich 0

Erin Simmons 16

Antonio Levi 75

Mabel Henderson 41

Paula Coffey 62

Tom Green 56

Hazel Willis 70

Marty Osterberg 0

Nancy Winders 90

$ ./task2 class01_students.csv class01_activity02.csv

Sherri Hurrington 44

William Rich 0

Erin Simmons 75

Antonio Levi 97

Mabel Henderson 29

Paula Coffey 89

Tom Green 62

Hazel Willis 90

Marty Osterberg 13

Nancy Winders 34

All students should be output in the same order as they appear in the student CSV file. If a student was absent for an activity, they should be awarded a grade of 0.

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.

.

  • free the memory for the activity and student arrays.

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.

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