Question: Extend the structure definition to use a personType structure rather than just a string for the customer name. Also, update the program to use this
Extend the structure definition to use a personType structure rather than just a string for the customer name. Also, update the program to use this new structure and move all the structure definitions to a separate .h file. C++
struct Date { int month; int day; int year; }; struct Car { float price; Date purchased; string customer; }; Car GetCar(ifstream& dataIn); void WriteCar(ofstream& dataOut, Car car); 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); car = GetCar(dataIn); } 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; } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
