Write a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The date in the output file will be nearly the same as the data in the input file except that you will print the names as last-name, first-name; each quiz score, and there will be one additional number at the end of each line: the average of the student's ten quiz scores. Both files are parameters. You can access the name of the input file with argv[1]. and the name of the output file with argv[2]. The output file must be formatted as described below: 1. First and last names appear togeter in a left-justified column that is 20 characters wide where the last name comes first and a space and then the first name. Read each name separately and then put them together into a larger correctly formatted string before trying to output them (you can use the concatenate two strings example in class as a reference). 2. Each quiz score should be listed in a right-justified column that is 4 characters wide. Note that if a student has fewer than 10 scores (they have missed one or more of the quizzes), your program will need to display the missing score(s) using 0 for each one. 3. The average should appear in its own column that is 10 characters wide. Note that if a student has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Description
Write a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The date in the output file will be nearly the same as the data in the input file except that you will print the names as last-name, first-name; each quiz score, and there will be one additional number at the end of each line:
the average of the student's ten quiz scores.
Both files are parameters. You can access the name of the input file with argv[1]. and the name of the output file with argv[2].
The output file must be formatted as described below:

1. First and last names appear togeter in a left-justified column that is 20 characters wide where the last name comes first and a space and then the first name. Read each name separately and then put them together into a larger correctly formatted string before
trying to output them (you can use the concatenate two strings example in class as a reference).
2. Each quiz score should be listed in a right-justified column that is 4 characters wide. Note that if a student has fewer than 10 scores (they have missed one or more of the quizzes), your program will need to display the missing score(s) using 0 for each one.
3. The average should appear in its own column that is 10 characters wide. Note that if a student has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10.
4. The average should be computed with an accuracy of two decimal places.

You should use at least two functions that include FILE handles in their parameter lists.(These functions may have other parameters as well.) Suggestion: One very useful strategy is to write a function that, given a FILE pointer, will extract out exactly one person's name and write it to the out put file. Write another function that, given a FILE pointer will extract out one person's quiz scores and list them in the output file along with the average score. Then use these two functions in a loop that will keep doing this until there is no more data in the input file. The feof function may be helpful for determining if you have reached the end of the input file

You may not use %s together with scanf (or fscanf) or gets, which are not safe as we mentioned in class. Don't use any library functions related to c-strings, e.g. strcpy, strlen, atoi,itoa, for the purpose of practice. You don't need to and should not use any non-string arrays.
Some test cases you may want to consider are the following:
• What if the input file is empty?
• What if a student does not have any quiz grades at all?
• What if multiple students in a row don't have any quiz grades?
• What if the last record in the file does not have a new line after it but rather ends with end of file?
• What if there are extra new lines at the end of the file?

When you run the program, because the output is written to a file, don't be surprised to see nothing in the output dialog. In order to see your results, you may use the technique that we learned in class to assign stout to your output file pointer temporarily so that you can check the result. After you finish debugging, change your code back.
A sample file, quiz_test. txt is available for download. The input file is shown below for your reference. This is NOT the file that will test your program. Don't assume that the input file will be exactly like this. Your program should be able to handle arbitrary numbers of records and you should consider all of the test cases listed above (or more).

quiz.txt
Aily Smith 98 100 90 99 100 95 100 95 99 100
Ruth Black 67 55 78 55 80 76 90 82 85
Eddy Whyte 69 86 70 85 89
Mike Someone
A sampe of the output file (for the above input file) is shown below for your reference.
G average.txt
Smith, Aily.
Black, Ruth
Whyte, Eddy
Someone, Mike
97.60
66.80
39.90
98 100
90
99 100
55
85
95 100
99 100
95
82
67
55
78
80
76
90
85
69
86
70
89
0.00
All program must have a section of comments at the beginning that give the program
number, your name, the date, the time you spent working on the program, and its purpose.
You will be graded on the correctness of your program, the comments, and the general layout
of your code (indentation, etc.)
A program that does not compile or link will not be graded.
At the top of your program you should have a comment that follows the below format:
Transcribed Image Text:quiz.txt Aily Smith 98 100 90 99 100 95 100 95 99 100 Ruth Black 67 55 78 55 80 76 90 82 85 Eddy Whyte 69 86 70 85 89 Mike Someone A sampe of the output file (for the above input file) is shown below for your reference. G average.txt Smith, Aily. Black, Ruth Whyte, Eddy Someone, Mike 97.60 66.80 39.90 98 100 90 99 100 55 85 95 100 99 100 95 82 67 55 78 80 76 90 85 69 86 70 89 0.00 All program must have a section of comments at the beginning that give the program number, your name, the date, the time you spent working on the program, and its purpose. You will be graded on the correctness of your program, the comments, and the general layout of your code (indentation, etc.) A program that does not compile or link will not be graded. At the top of your program you should have a comment that follows the below format:
Submission
A C file (project4.c), up to 20 times on zyBooks.
Points Requirements
34
Pass the test cases. The test cases
Deductions will apply if you violate the
check the name, scores, average, requirements described below in red (-2
and their formats.
pts for each violation).
Use at least two functions with
FILE* as an argument
Variables should be local, not global
Programming style (including
but not limited to the ones listed Use meaningful names for variables and
to the right)
ones; reasonable program structure
10
functions.
Sufficient comments in the program.
Should have comments for your func-
tions.
Indentation should indicate program
structure.
Program comments header (name, pur-
poses of assignment, etc).
Transcribed Image Text:Submission A C file (project4.c), up to 20 times on zyBooks. Points Requirements 34 Pass the test cases. The test cases Deductions will apply if you violate the check the name, scores, average, requirements described below in red (-2 and their formats. pts for each violation). Use at least two functions with FILE* as an argument Variables should be local, not global Programming style (including but not limited to the ones listed Use meaningful names for variables and to the right) ones; reasonable program structure 10 functions. Sufficient comments in the program. Should have comments for your func- tions. Indentation should indicate program structure. Program comments header (name, pur- poses of assignment, etc).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education