Question: Note. Read through the whole of Question 4 below before you attempt to answer the questions that follow Also provide only the member functions requested
Note. Read through the whole of Question 4 below before you attempt to answer the questions that follow Also provide only the member functions requested and required by the question Welcome_to_the_World is a new maternity hospital that captures the following information for each baby bor name, contact details, sex (male or female), weight, and length This information is collected in a file called Babies dat on a daily basis The average weight for a baby is 3 2 kg and the average length is 52 cm Welcome_to_the_World wants to check up regularly on babes smaller than that, ie weighing less than 3 2 kg and measuring less than 52 cm At the end of every day, a list of all smaller-than-average babies born, is copied to a file called ExtraCareBabies dat To assist Welcome_to_the_World in this process, write a program that reads the data for each baby from the file Babies dat, and determines which babies should receive extra care because they are smaller than average As an example of the record kept for a baby, baby Mpho Nkosi's address is 231 Nelson Drive. Soweto, he weighed 3 57kg at birth and was 53 cm long (see the first record in the data file Babies dat) If Babies dat contains the following data Mpho Nkos. 231 Nelson Drive, Soweto - 3 57 53 Eleanor Witbooi 45 Blue Heaven Flats, Lavender 111 f 2 86 50 Jonathan Cleggerty 87 Church St, Pretoria m 3 2 51 Calay Pravin 39 Blue Water Bay, Durban 31 52 we expect the following output in file ExtraCaceBabies dat Eleanor Witbooi 45 Blue Heaven Plats, Lavender Hill f 2.86 50 To implement this program, define a class Baby that represents the data Welcome_to_the_World keeps for each baby This class has five member vanables name, a stnng that holds the name of the baby address, a string that holds the address of the baby sex, a char variable indicating the sex of the baby with an 'm' for a boy and ant for a girl weight, a double value representing weight of the baby in kilograms length, a double value representantenne . CATES we expect the following output in file ExtraCareBabies dat Eleanor Witbooi 45 Blue lieaven Plats, Lavender Hall f 2.86 50 To implement this program, define a class Baby that represents the data Welcome_to_the_World keeps for each baby This class has five member vanables name, a string that holds the name of the baby address, a string that holds the address of the baby sex, a char variable indicating the sex of the baby with an 'm' for a boy and an " for a girl weight, a double value representing weight of the baby in kilograms length, a double value representing length of the baby in centimetres In addition, the class should have the following member functions A default constructor that initializes the data members name and address to empty strings, sex to an empty character and weight and length to 0 An overloaded constructor that sets name, address, sex, weight and length to specified values A destructor that does not perform any action Accessor functions to return the baby's sex member and name An overloaded companson operator to compare two Baby objects The overloaded companson operators is implemented as a friend function with two parameters to compare two babies This function returns true if both the weight of the first Baby object is less than that of the second Baby object and the length of the first Baby object is less than that of the second Baby object, and false if not An overloaded stream extraction operator>>(implemented as a friend function) so that it can be used to input values of type Baby An overloaded stream insertion operator 1/1. Include fales needed using namespace std; int main() 2 1/2 Declare input fale, open frie Babies.dat and 1/check that file exists 1/3. Declare output file, open file //ExtraCareBabies dat and check that fale exista 5 6 //5 Instantiate an object averageBaby using the 1/overloaded constructor and initialising the weight for an average 1/baby to 3 2 kg and the length to 52 cm All other member variables 1/ should be instantiated to blank strings or characters while //6 Extract an object newBaby from file 1/babies dat 1 37/7 Compare object newBaby wath // object averageBaby 8 1/8 Output newBaby to file 1/ExtraCareBabies dat af necessary if ( 7 1 9 /19 Close files return 0. } 44 4 4 1 Write a statement to declare an array ourBabies of fifty Saby objects (1) 4 4 2 Assume nrBabies Baby objects are stored in array our Babies Use the array our Babies and write a program fragment to display the names of all male babies in the array (3) QUESTION 5 [15] Consider the class specification (interface) for the class insurance pol.cy below class Insurance policy + public Insurance policy(). Insurance policy (int pnr, string pholder, douple aRate). void snowPolicy (ostream& out) const, void set Policyant pne, string pholder, double aRate). unt get_pr (coast. string get_pholder () const, double get_aRate() const, Drivate int policyNr. string policyholder. double annualRate } 51 Define a new class Car Insurance that inhents the functionality of the class Insurance policy The class CarInsurance has additional member vanable, excess. Class an
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
