Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

“Baby names and birth weights” Introduction Babies are weighed soon after birth

ID: 3790612 • Letter: #

Question

                                                                        “Baby names and birth weights”

Introduction

Babies are weighed soon after birth and this birth weight is recorded as part of a baby’s medical record. A low birth weight indicates increased risk for complications and such babies are given specialized care until they gain weight. Public health agencies, such as the Centers for Disease Control and Prevention (CDC) in the United States, keep records of births and birth weights. In this project you will write principled object-oriented C++ code to read a data file recording birth information and answer questions based on this data.

Objective

You are given data in text files - each line in a text file is a baby girl’s first name followed by her birth weight in grams (an integer). The text file could contain a large number of such lines. Write code to answer the following questions:

- How many births are recorded in the data file?

- How many babies have a given first name?

- How many babies are born with a low birth weight (less than 2,500 grams)?

- Which baby name is the most popular?

The code

You are given skeleton code with many blank spaces. Your assignment is to fill in the missing parts so that the code is complete and works properly. The code is in three files:

- main.cpp contains the main function and a set of unit tests, implemented using assert statements - each assert statement compares the output of your code with the expected correct answer. Since the provided code is only a template, all the tests will fail immediately with runtime errors. As you add functionality and fix any bugs that may arise, the tests will be able to get further and further. Do not edit this main.cpp file.

- Baby.h contains code for a “Baby” data class. This class is incomplete and you should complete it.

- MedicalRecord.h contains a class whose methods can return answers to the questions asked in this project. You can use (dynamic) arrays but not any of the STL containers (such as std::vector). This class is incomplete and you should complete it.

Hints

MedicalRecord.h will require the use of an array-based data structure of Baby objects. Note that private data members are also incomplete. Feel free to add private member variables to both MedicalRecord.h and Baby.h as you need. There is more than one way to solve this problem!

In summary, do the following:

- Fill in the missing blanks in the skeleton code. Test your progress with the test programs or critic tool. Push your changes to GitHub at regular intervals.

- Check that your code works one last time.

main.cpp contains

Baby.h contains

MedicalRecord.h contains

baby_data_small.txt contains

baby_data_large.txt contains

Explanation / Answer

Baby.h contains

MedicalRecord.h contains