Question: 4 Hierarchical Records Use program Cars for Exercises 4 - 5 . EGR 1 2 1 Introduction to Computer Programming in C + + College

4 Hierarchical Records
Use program Cars for Exercises 4-5.
EGR 121 Introduction to Computer Programming in C++
College of Engineering, California Baptist University |5
ifstream dataIn;
ofstream dataOut:
dataIn.open ( "cars.dat");
dataOut.open ( "cars.out") ;
cout fixed showpoint;
car - GetCar( dataIn );
whlle( dataIn )
f
car.price - car.price *1.10;
VriteCar( dataout, car );
car - GetCar( dataIn ) ;
}
return 0 ;
}
CarType GetCar( ifstream dataIn)
Exercise 4:
Using Notepad, enter the following data into a file named cars . dat:
Run the program. Show the content of the output file cars.out.
Exercise 5:
Modify the CarType struct to add a Boolean type member called sold and a DateType member called
soldDate. In the GetCar function, initialize sold to false. In the while loop in function main, ask user
whether the car has been sold for each car record read from cars.dat. If the car is not sold, write the record
to cars.out with the price increased by 10% as before. If the car is sold, call function CarSold. The void
function CarSold takes one parameter of CarType. It should ask the user when the car was sold, and
update two members of the reference parameter of CarType: set sold to true, and set soldDate with the
sold date entered by user, then write the updated record to file carssold.our instead of cars.out. Run your
program using file cars.dat and show your test results with I/O in console window, contents in
carssold.out and cars.out. You can assume that Mary's and Betty's cars have been resold. Include your
modified C++ program in the report.
 4 Hierarchical Records Use program Cars for Exercises 4-5. EGR 121

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!