Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started