Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Begin by adding the empty .txt files listed below to the project. oop04in.txt oop04out.txt Create StudentArrayV4 methods add_all_from(), write(), and add_from() as follows: void add(

Begin by adding the empty .txt files listed below to the project.

oop04in.txt

oop04out.txt

Create StudentArrayV4 methods add_all_from(), write(), and add_from() as follows:

void add( const Student& new_student ); int add_all_from( istream& infile ); ostream& write( ostream& outfile=cout ) const; void add_from( istream& infile );

The add() method shown here is an overloaded add(). It will take a Student object (by const reference) and add it to the array, using the same rules as the zero-parameter add(). That is, if there is room left in the physical array, the new student is added at the end. If the physical array is full, its size should be increased by 3 (by allocating a new array and copying over the existing pointers) and then the new student should be added at the end of the logical array. (Refer back to the material from the in-lab if needed.) When you finish this version of add(), you might be able to re-factor the version of add() you wrote in lab to make use of it so that there is no repeated code.

The add_all_from() method invokes method add_from(), creating new Student objects one at a time, until the end of the input stream is reached; the number of Students that were successfully read should be returned.

The add_from() method will accept the input file as a parameter, and is responsible for extracting all available data for the student, creating that student, and adding the student to the StudentArrayV4 collection using the overloaded add() method described above. This method should add a student only if there is enough valid information in the stream to constitute a student record. For our purposes, if the stream contains at least a valid name and id number, the record is valid (see the input file specification below for more specifics).

The write() method should replace the write() method you created in lab. It will direct the printing of each Student object's data to the indicated stream (the format is shown later in this text).

Write the test data file oop04in.txt and make sure the methods work correctly with it. Example contents might include the following.

u do not know in advance how many students may be in the input file, or how many scores each student will have (and not all students need have the same number of asignments). The format does guarantee the following:

Each line represents one student.

The student name is first, followed by a colon. Name is required.

The student ID number is next, possibly preceded by some amount of whitespace, which must be ignored. Student ID is required.

Following the student ID will be zero or more scores, separated by some amount of whitespace. Scores are optional.

Function main() should prompt the user for the names of files to be read and written. Add code to main() to open the input and output files, and perform testing for the new functionality you are adding.

Direct the program to create the output file oop04out.txt. The contents of this file might appear as follows, given the input data shown above.

 scores name id# grade avg 1 2 3 Able 666 D 63.00 61 63 65 Baker 777 C 73.00 71 73 75 Charles 888 B 83.00 81 83 85 Dunlap 999 A 93.00 91 93 95

out put should look like this.

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

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago