Read all car information from the input file (carsInStock.txt) and save it to th
ID: 3539503 • Letter: R
Question
Read all car information from the input file (carsInStock.txt) and save it to the correct type of object. In the input file each line will start with either T or 'D' to indicate the classification of the car. You should use arrays to save the information about the current collection of cars. Example of 2 lines in the carsInStock.txt and carsFxpectedToArrive.txt files are: D Ford FI50 2002 17000 Truck MI I Toyota Camry 2004 20000 Sedan Japan 10 I indicates an imported car, and you have to use an Import Car object to store its information. D indicates a domestic car, and you have to use a Domestic Car object Output would be a listing of cars in the carsCatagoiyWise.txt file and console as follows: Note: Make sure that you are using polymorphism to call the appropriate to String member function. The to String function in the sub classes should be redefined to override the to String function in the super class.Explanation / Answer
Sample output on both console and a textFile
Imported Car List :
1. I Toyota Camry 2014 20000.0 Sedan Japan 10
2. I BMW 325i 2013 30000.0 Sedan Germany 8
3. I Toyota LexusRX30 2015 42000.0 Sedan Japan 10
Domestic Car List :
1. D Ford F150 2012 17000.0 Truck MI
2. D Chrysler Pacifica 2013 18000.0 Sedan TX
3. D Chevrolet TahoeLS 2010 7000.0 Coup TX
4. D Chevrolet Silverado 2011 10000.0 Van MI
5. D Ford Econoline 2012 16000.0 Sedan MI
Number of imported cars : 3
Number of Domestic cars : 5
Total : 8
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.