Summary: Write a program that determines letter grades for students in a class, using your understanding of control flow, arrays (and/or pointers, structures), disk files, and error conditions in C.

Description: Your program accepts two command line arguments. The first argument is the name of a disk file that contains the names of students, and their test scores, separated by commas followed by one or more spaces. Each line in the file will contain scores for one student. The second argument to your program is the name of an output disk file. Your program creates a new output disk file using that name. You will write grade information of all students whose information was read from input file, in a sorted order into this output file. You will be writing one line in the output file for one student. You will write name of one student and the letter grade he/she got in the class in each line (you should format the texts in the output file). The format of the data in the input file is fixed, however the number of students in the input file is unknown during compile time. The name of input and output files could be anything and only known during run time. Besides writing to the output file, you will also need to display the averages of scores along with minimum and maximum scores for each test in the screen/console.

Calculation: The test scores are weighed. There are four quizzes, 40% total, midterm I is 20%, midterm II is 15% and the final is 25%. All scores in the input file are recorded out of 100. You need to apply the weight for each score in the program to calculate the final score. The final score is tabulated as follows:

Final Score= quiz1 * .10 + quiz2 * .10 + quiz3 * .10 + quiz4 * .10 +midi* .20 + midii * .15 +final* .25

Determination of letter grade is according to the following logic:

Final Score>= 90% then letter grade is A, 80%-89% B, 70%-79% C, 60-69% D, <= 59% F

Sample input data file: input_data.txt (the input data format is: name, quiz1, quiz2, quiz3, quiz4, midi, mid ii, final -Assume that data will be correctly formatted as described.), e.g.:

Thui Bhu, 100, 90, 80, 100, 89, 99, 88
Ariana B. Smith, 90, 90, 100, 100, 99, 100, 95
Emily Ganz ales, 100, 90, 100, 70, 78, 78, 80
Jennifer L, 80, 90, 90, 100, 89, 99, 85
Maria Jones, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 38, 62, 65, 60, 50
Escobar Morris, 83, 77, 88, 76, 79, 72, 76
Anne Latner, 80, 80, 85, 95, 90, 95, 90
..
<< more if there are more students >>

Sample output file: output_data.txt (the output format is: Name: letter grade, sorted by full name (first name+middle initial+last name), e.g.

Letter grade for 8 students given in input_data.txtfile is:

Anne Latner: B
Ariana B. Smith: A
Bill Gates: F
Emily Gonzales: B
Escobar Morris: C
Jennifer L: B
Maria Jones: D
Thui Bhu: A
<< more if there are more students >>

Sample Run of the program (name of your program is Lettergrader): Remember that there are two sets of outputs. Letter grade is written into the output disk file (which is not shown on the screen), only score averages are displayed on the screen (and are not written into the disk file).

Example Run 1: see image.

Sample Run 2 (it will have different set of data and so will be the output): see image.

Note:

1) You will be able to run this application with your choice of IDE as well, including Visual Studio by providing command line arguments in the settings. All IDEs allow you to enter the command line arguments.

2) The disk output for different input file will be different, however, the format of the output should be similar as shown in the example above (output_data.txt)

Design Hint: You are free to use your own design however; here is a guide to make it modular design:

  • Storing data into memory using suitable data structures will help you write code, which will be modular. You then need to calculate the averages by going through all the data for each test score for all the students and divide by the number of students (you will only know the number of students during run time).
  • You are free to use any data structures you want. Parallel arrays for all the scores is one easy way (for simplicity you can assume maximum number of students to be 100). Alternatively, you can create an array of structures to store data, one structure will hold one student's all the scores and name.
  • Other assumptions: Assume, first name do not exceed 40 chars and last name 60 chars. Names may have middle initial (with a period). Data elements will be coma separated with unknown number of spaces after comma. Each line will have valid data, meaning, exact number of scores, float numbers etc.
  • If you want to explore pointers, then a linked list would be the best choice. This is especially helpful, as you do not know how many student records are in the input file until you have read all the data in it.
  • I will not penalize you for choosing one data structure vs. another, or if you assume 100 to be the maximum number of students, as long as you make sure to calculate the average using the actual number of students during run time (you need to keep a running total in that case). Make a decision on your own regarding data structures; that in itself is good experience.
  • You need to choose (or write your own) sorting algorithm to sort the data so that you can display in sorted order by name. Also, you need to write proper functions to give you minimum, maximum, and the average scores in each class.

You can write your application spread out in multiple .c and .h files (remember that there is only one main in any application, even if you have multiple .c and .h files for that application).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.