View the step-by-step solution to:

1010 (202, 203) Program 4 SP16 - Dr. Lin Due date: 04-22-2016 (Friday) 11:59pm (close date: 04-27-2016(W) 11:59pm) Submission: C source file,...

Need this answer in 3 hours its very urgent and it should work and follow the guidelines

COMP.1010 (202, 203) Program 4 SP16 - Dr. Lin Due date: 04-22-2016 (Friday) 11:59pm (close date: 04-27-2016(W) 11:59pm) Submission : C source file, program4.c , on Blackboard Points : 20 Description: Treat this like a take home exam. You may not work together. Write a program to compute average grades for a course. The course records are in a single file (named quiz.txt) 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 data in the output file (named average.txt) 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. The output file must be formatted as described below: (1) The output file should contain a line (or lines) at the beginning of the file providing appropriate column headings. Use formatting statements to make the layout clean and easy to read. (2) first and last names appear together in a left justified column that is 20 characters wide where the last name comes first, then a comma 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. (3) 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 or empty space(s) for each one. (4) The average should appear in its own right justified 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. After writing the required data to an output file, your program will close all files and then copy the contents of the “output” file to the “input” file by reopening the input file for writing and opening the output file for reading. Thus, the net effect of the program is to change the contents of the input file. Do not attempt to copy the output file to the input file until you
Background image of page 1
COMP.1010 (202, 203) Program 4 SP16 - Dr. Lin have thoroughly tested and debugged the rest of your program to ensure that it operates correctly. You should use at least two functions that include FILE pointers in their parameter lists. (These functions may have other parameters as well.) The input file should be called quiz.txt and the output file should be called average.txt . 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 there are extra new lines at the end of the file? What if the last record in the file does not have a new line after it but rather ends with end of file? Name your source code file program4.c . One very useful strategy is to write a function that, given a FILE pointer, will extract out exactly one person’s full 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. A sample of the input file is shown below for your reference. This is NOT the file that will test your program. Don’t assume the input file will be exactly like this. Your program should be able to handle arbitrary number of records and you should consider the test cases listed above (or more). A sample of the output file (for above input file) is shown below for your reference. The header could look differently.
Background image of page 2
Show entire document

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question