CS240 - Introduction to Computing III mp04 (Linked List) Solution
Objectives
▪ To use a linked list to process state data
▪ To read from a file
▪ To use pointers and dynamic memory management
Project setup
Create the project mp04.<FirstLast. Replace FirstLast with your name and do not include the < brackets. For instance, mp04.SocratisTornaritis.
Add the provided files to your project:
main.cpp
States.hpp
LinkedList.hpp
The folder mp04.Firstlast containing just the source file(s) and text file(s), is the one that you must zip and upload. Do not upload any IDE specific files.
Refer to the appropriate "how to" tutorial notes available on the course website, for instructions on how to create a project and manage its files.
Problem description:
A text file, states.txt, is provided with state information. Your program will read the state data into seven instances of the States class. Each instance will correspond to the data sorted by one of the seven fields (abbreviation to orderInducted).
The data thus will be read in seven times, once for each instance. The instances will then be sorted by their respective field, and finally added to a LinkedList instance. This LinkedList instance will contain States nodes.
The driver will offer the end user the option to list the data in one of the seven sort fields. Refer to the screen cast below.
Program requirements:
(1) Code the implementation of the States class.
Refer to the imbedded comments in the States.h file for details.
(2) Complete the implementation of the partial main.cpp
Implement the TODOs inside the provided main.cpp file.
As you write your programs from here on out, documentation will be desirable and an essential part of your code. Add the following section to each of your programs to identify relevant information to anyone reading your code. The sample below is what I used for Main.java, so make the appropriate changes to reflect your current/accurate information. This is just a sample, so feel free to add to it if you want, but do not remove anything.
/* File: <filename
* Name: <your name
* Revised: <date authored
* Course: CS240 - Introduction to Computing III
*
* Desc: <program description
*/
Select sort field [A]bbreviation, [N]ame, [C]apital, [P]opulation, A[r]ea, [Y]ear Inducted, [O]rder Inducted, [Q]uit: a
Abbreviation Name Capital Population Area Year Inducted Order Inducted