Question

Write a C program to compute average grades for a course. The course records are in...

Write a C 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 data 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 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 such that 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. Use your read string function to read each name separately and then put them together into a larger correctly formatted string before trying to output them. Each quiz score should be listed in a right justified column that is 4 characters wide, and 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; these students are assumed to have missed one or more of the quizzes. 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. 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 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?

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Write a C program to compute average grades for a course. The course records are in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Java - In NetBeans IDE: • Create a class called Student which stores: - the name...

    Java - In NetBeans IDE: • Create a class called Student which stores: - the name of the student - the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into...

  • C++ Write a program that reads students’ names followed by their test scores from the given...

    C++ Write a program that reads students’ names followed by their test scores from the given input file. The program should output to a file, output.txt, each student’s name followed by the test scores and the relevant grade. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, testScore of type int and grade of type char. Suppose that the class has 20 students. Use an array of...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • 12.8 GPA reports using files This program is to compute and write to a file the...

    12.8 GPA reports using files This program is to compute and write to a file the GPA for student scores read from an input file. As in Lab 7.5, the point values of the grades are 4 for A, 3 for B, 2 for C, 1 for D, and 0 for F. Except for the grade A, where + has no effect, a + after the letter increases the point value by 0.3, and except for F, where a -...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • c++ reading file that contains names and scores to compute averages, return scores when names are inputed and return if a students scores is aobve equal to or below the average

    Given a score file named as scores.txt, the named file is posted alone side with the assignment. The score file has two part: first line is number of students and the rest is a list of names with scores. For example: 3 Tommy 35.5 John 77.2 David 59.4 The first function should be named as getScore and it takes a string parameter as input that is a student’s name, you then open the given score file, read the contents and return the student’s score stored in...

  • In C++ write a complete and correct x++ program that generates student email addresses and prints...

    In C++ write a complete and correct x++ program that generates student email addresses and prints them to the screen based upon the data found in an input file, called students . txt. Each line of the space, followed by the student’s last name. Every email address is to be of the form [email protected]. In general, each username has four parts in this order: (i) the student; last name in lowercase letters; (ii) a number between 10- 99 generated at...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

  • What to submit: your answers to exercises 2. Write a Java program to perform the following...

    What to submit: your answers to exercises 2. Write a Java program to perform the following tasks: The program should ask the user for the name of an input file and the name of an output file. It should then open the input file as a text file (if the input file does not exist it should throw an exception) and read the contents line by line. It should also open the output file as a text file and write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT