Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Project The txt file has the following format: 5 characters - dog name 5 characters - owner name 7 characters - dog ID 2

C++ Project

The txt file has the following format:

5 characters - dog name

5 characters - owner name

7 characters - dog ID

2 characters - age, in years (2 digits)

Dog ADT

Dog has the following members:

String - dog name

String - owner name

Char - insurance code(1letter in dogs ID)

String - dog ID

Int - age

Define a struct that matches this description.

There are some differences between the input fields and the form of the Dog members. The dog ID field in the input is an example of a coded key. It may look like a 7-character ID, but in reality it contains two distinct fields. The first character is an insurance code. Then 6 characters are a sequence number. You can assume that sequence numbers are assigned such that every dog has a unique 7-character ID.

Processing the input

Open the input file. Check for successful open. Use the read function to read each record into a character array large enough to hold the entire record. For each input file record, dynamically allocate and populate a Dog object. Note that to populate some of the Dogs fields, youll need to perform some type of conversion. Use a pointer array to manage all the created dog variables. Assume that there will not be more than 20 input records, so the size of the dog variable pointer array will be 20.

Using a pointer array

Initialize each element in the array of pointers to nullptr. As you read input records and create new dog variables, point the next element in the pointer array at the new dog. Later, when you loop through the pointer array to process the dog variables, youll know that there are no more dogs when you come across a pointer with a null value. Display the Dog objects When you hit EOF on the input file, close it, and display the entire list of dogs.

Write a loop, after closing the file to do this, do not create the report while youre in the loop that reads input records.

Your output should look something like this:

Dog name Owner Name Insurance code Sequence Age =================================================================

Marti Steven C 543245 5

Berry Maria D 452617 2

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

Know the principles of effective service recovery systems.

Answered: 1 week ago

Question

Explain the service recovery paradox.

Answered: 1 week ago