Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions