Problem 172

Reading What You Wrote

Again, make a class to store information about a car. It should contain fields for:

  1. Create an array of type Car with five slots. (So far, this is the same as the previous assignment.)
  2. Ask the user for the name of a file, and then open that file and read all the data from that file into the array.
  3. Finally, display the values in the array.
From which file do you want to load this information? cars.txt
Data loaded.

Car 1
	Make: Toyota
	Model: Camry
	Year: 1985
	License: 622-VRX

Car 2
	Make: Chevrolet
	Model: Chevette
	Year: 1980
	License: J43-SMB

Car 3
	Make: Honda
	Model: Civic
	Year: 1993
	License: 883-RS9

Car 4
	Make: Ford
	Model: Mustang
	Year: 1966
	License: AZUCAR

Car 5
	Make: Dodge
	Model: Neon
	Year: 1996
	License: G74-LLC

◄ 171: Storing Data in a File 173: Sorting an Array of Objects ►



Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.