Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ You will be given two data files, one with a list of names and one with a list of three grades per row. The

C++

You will be given two data files, one with a list of names and one with a list of three grades per row. The list of names in the first file represent students. The list of grades in the second file represent the grades for each student (they are parallel arrays). The goal is to read the student names and grades, calculate their averages, determine their letter grades and produce a report.

Step 1: Read Student Names into an Array

Create or import the file StudentNames.txt into your project. Note that this file needs to be in the same folder as your .cpp program. Even though it may look like it is in the project via the Solution Explorer in VS, it is possible that it is not. Be sure to understand how the project is saved in your file system and double check there.

Follow program 8-3 in your book to read in your first array of student names. Remember that names are strings rather than ints and you must include the string library. Once you have successfully read in your student names, move on to creating and reading in data for the two dimensional array.

Once you have your array reading in from the file, re-read and follow section 8.7 and 8.8 (watch the video note), and move the reading of your array out of the main and into its own function. This will keep your main de-cluttered. You can wait for this step until the end if youd like. Modularization of this program is worth 10 points of your grade.

Your file will look like this (4 students): Donald, Daisy, Mickey, Goofy.

Step 2: Read grades into a two dimensional array. Create an array 4X4 to handle student grades. You will be given three grades per student, and you will average those and populate the forth column for that student. This will be a parallel array (section 8.6) to the students array. So the first row belongs to the first student, second row belongs to the second student and so forth. You will have a file of three grades per student. You will fill in the fourth column with the grade averages. Your file will look like this:

100 87 72

73 65 45

100 45 70

48 80 89

So, your 4X4 array should be populated like this:

100 87 72

73 65 45

100 45 70

48 80 89

Follow Program 8-19 to read the data into a two dimensional array. This ideally should be in its own function, read pages 550 & 551, but more importantly 551 where the two dimensional typdef statement is explained. Remember if you keep the two dimensional array processing in main, that is OK, modularization in this program is worth a total of 10 points. So if you want to, handle modularization (putting processing in functions) last, after you have your program running.

Step 3: Calculate and populate each students average Now that you have the grades read in for each student, we need to populate each students average of the three scores into the fourth column position. Read the section about summing the rows of a two-dimensional array on page 551-552. Keep in mind that your array is a bit different, because three columns are populated, but not the forth. So your inner loop will have only 3 columns to add, not 4. Then, before you move onto the next row, you need a statement to populate the average into the 4 column position. This column will eventually be filled with the averages. The first row, column 4 will be the average of 100, 87,and 72 for now leave it empty This is a good time to use the debugger to view what is happening line by line in your code. Set breakpoints, understand each line as it executes. The debugger is your best friend, this step should also be in its own function.

Step 4: Write a new array with the students name and letter grade Create a third two dimensional string array. This array will have the students name and letter grade, based on the files given, it will look like this:

Donald B

Daisy D

Mickey C

Goofy C

You can populate this array in main, however, the calculation to determine and return the letter grade should be in its own function. The letter grade should be a string, because the names are strings. Remember you cannot have two different types of data in the same array (you may think letter grade should be a char, but not in this case).

Step 5: Write your output to the console and a file. Loop through your array that holds just the names and letter grades, output this to a file and to the console. Use a function for this processing. With this data the output is:

Donald B

Daisy D

Mickey C

Goofy C

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions