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

Exercise 1: Augment Car in program Cars with the following two members: sold A b

ID: 3656158 • Letter: E

Question

Exercise 1: Augment Car in program Cars with the following two members: sold A boolean variable soldDate If (sold), then soldDate contains the date of sale; otherwise soldDate is undefined Function GetCar should 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. 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. #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, ' '); 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; }

Explanation / Answer

please repost as every thing has got mixed up and we are unable to read