$25
Requirements:
1. Create a class named State that will store information about a US state and provide methods to get, and set the data, and compare the states.
a. Data attributes: State Name, Capital City, State Abbreviation, State Population,
Region, US House Seats
b. Initializer (__init__)
c. Getter and setter methods for each field
d. __gt__ method so that two State objects can be compared based on state names
e. __str__ method so that a state object can be printed like a string 2. Create a program that will:
a. Read a file (csv) of states and create a list of state objects containing that data.
b. Offer the user the following options:
1) Print a state report
2) Sort by state name (using Quick Sort)
3) Sort by population (using Radix sort)
4) Find and print a given state (using binary search if the data is sorted by state name, sequential search if not)
5) Quit
c. Implement the given option, then prompt again. (deal with invalid choice)
Your program should have functions for options 1-5.
d. The State report in option 1 should be in this form:
State Name Capital City State Abbr State Population Region US House Seats
------------------------------------------------------------------------------------------
Florida Tallahassee FL 19,552,860 South 27
Pennsylvania Harrisburg PA 12,773,801 Middle Atlantic 18 Massachusetts Boston MA 6,692,824 New England 9
e. The State report in option 5 should be in this form:
State Name: Florida
Capital City: Tallahassee
State Abbr: FL
State Population: 19,552,860
Region: South
US House Seats: 27
Provide docstring comments:
Comments for a module (must be at the top):
””” Detailed description of the module.
Author: <your name>
Version: <date you last changed the class>
Email: <your UNF email>
”””
Comments for a function definition (must be the first thing inside the function):
”””
Description of the purpose of the function, the meaning of the input parameters (if any) and the meaning of the return values
(if any).
:param parameter description of the parameter (one for each)
:return description of the return value
:raise exceptions that may be raised in this function
”””
Comments for a class definition (must be the first thing inside the class)
””” Detailed description of the class.
”””
Example Ouput:
CAP4640/5605 Project 1
Instructor: Xudong Liu
Enter the file name: States.csv
There were 50 state records read.
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 1
State Name Capital City State Abbr State Population Region US House Seats
------------------------------------------------------------------------------------------
Louisiana Baton Rouge LA 4,625,470 South 6
Wisconsin Madison WI 5,742,713 Midwest 8 New Mexico Santa Fe NM 2,085,287 Southwest 3 . . .
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 3
States sorted by Population.
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 1
State Name Capital City State Abbr State Population Region US House Seats
------------------------------------------------------------------------------------------
Wyoming Cheyenne WY 582,658 West 1
Vermont Montpelier VT 626,630 New England 1 North Dakota Bismarck ND 723,393 Midwest 1 . . .
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 4
Enter the state name: Florida
Sequential search
State Name: Florida
Capital City: Tallahassee
State Abbr: FL
State Population: 19,552,860
Region: South
US House Seats: 27
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 4
Enter the state name: Canada
Sequential search
Error: State Canada not found
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 2
States sorted by State name.
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 1
State Name Capital City State Abbr State Population Region US House Seats
------------------------------------------------------------------------------------------
Alabama Montgomery AL 4,833,722 South 7
Alaska Juno AK 735,132 West 1 Arizona Phoenix AZ 6,626,624 Southwest 9 . . .
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state
5. Quit
Enter your choice: 4
Enter the state name: Kentucky
Binary search
State Name: Kentucky
Capital City: Frankfort
State Abbr: KY
State Population: 4,395,295
Region: South
US House Seats: 6
1. Print a state report
2. Sort by State name
3. Sort by Population
4. Find and print a given state 5. Quit
Enter your choice: 23
Invalid choice enter 1-5: 0
Invalid choice enter 1-5: A
Invalid choice enter 1-5: 5
Have a good day!