A local car dealership had a need for an inventory tracking program. The program written uses parallel arrays to maintain a list of cars that are in inventory. In this program the cars are maintained as objects. At the end of the day the arrays are added to a database. The parallel array structure uses six separate arrays to hold separate pieces of data on each car object in inventory. Those arrays are: make, model, year, MSRP, cost, and lowestSalePrice.
Both make and model are arrays of strings. This is because both make and model are represented by words. The variable year contains short integers such as 1992, 2002, 2012,… representing the year of manufacture of each vehicle. MSRP, cost and lowestSalePrice are all floating point integers. MSRP, which stands for Manufacturer Suggested Retail Price, is the dollar amount the manufacturer suggests each car is sold for. Cost is a dollar amount which represents the cost to the dealership for each car. Finally, lowestSalePrice is a dollar amount which represents the lowest acceptable sale price of each vehicle.
An example of the parallel array:
String make = { “Honda”, “Toyota”, “Nissan”, “Ford”}
String model = { “Accord”, “Camry”, “Versa”, “Aerostar”}
Short year = { 2010, 1999, 2004, 1967}
Float MSRP = { 24999.99, 26469.99, 17469.99, 19999.99}
Float cost = { 15000.00, 17000.00, 12000.00, 10000.00}
Float lowestSalePrice = { 20999.99, 21999.99, 15500.99, 11999.99}
An example of how these arrays