Question

I have spent more than six hours trying to get this program to
work, but I cannot get it to work. This is a skeleton and
description about it. Lesson 10-5 Hierarchical Records This lesson
works with program Carsdefined in the Prelab assignment. Exercise
1:Augment Carin program Carswith the following two members: sold A
Boolean variable soldDate If (sold), then soldDatecontains the date
of sale; otherwise, soldDateis undefined. Function GetCarshould
initialize sold to false. Write a function CarSold that takes
variables of type Date and Car and records that the car has been
sold and the date. Before invoking PrintCar, write the car owner’s
name on the screen and ask if the car has been resold. If it has,
call function CarSold and then write the car to file dataSold
rather than file dataOut. Run your program using file cars.dat. Let
Betty’s and Alice’s cars be resold. Exercise 2: Rewrite Car so that
soldDate and the new owner’s name are encapsulated into a struct
member soldTo. If the car has been resold, prompt for and read the
new owner’s name. Run your program again using cars.dat. Let
Betty’s car be sold to John and Alice’s car be sold to Cliff. //
Program Cars reads a record from a file and writes // its contents
back to another file with the price member // increased by 10%.
#include #include #include using namespace std; struct Date { int
month; int day; int year; }; struct Car { float price; Date
purchased; string customer; }; Car GetCar(ifstream& dataIn); //
Pre: File dataIn has been opened. // Post: The fields of car are
read from file dataIn. void WriteCar(ofstream& dataOut, Car
car); // Pre: File dataOut has been opened. // Post: The fields of
car are written on file dataOut, // appropriately labeled. int main
() { Car car; ifstream dataIn; ofstream dataOut;
dataIn.open("cars.dat"); dataOut.open("cars.out"); cout <<
fixed << showpoint; car = GetCar(dataIn); while (dataIn) {
car.price = car.price * 1.10; WriteCar(dataOut, car);
GetCar(dataIn, car); } return 0; }
//***************************************************** Car
GetCar(ifstream& dataIn) { Car car; dataIn >>
car.customer; dataIn >> car.price >> car.purchased.day
>> car.purchased.month >> car.purchased.year;
dataIn.ignore(2, '\n'); return car; }
//***************************************************** void
WriteCar(ofstream& dataOut, Car car) { dataOut <<
"Customer: " << car.customer << endl << "Price: "
<< car.price << endl << "Purchased:" <<
car.purchased.day << "/" << car.purchased.month
<< "/" << car.purchased.year << endl; }