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,

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please write the code in c

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,
Transcribed Image Text: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 we 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 output 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.
Transcribed Image Text: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 we 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 output 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY