Question: 4 Hierarchical Records Use program Cars for Exercises 4 - 5 . Run the program. Show the content of the output file cars - out.
Hierarchical Records
Use program Cars for Exercises
Run the program. Show the content of the output file carsout.
Exercise :
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 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.out instead of cars.out. Run your
program using file cars.dat and show your test results with IO 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 program in the report.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
