This Java application processes and analyzes data from OpenDataPhilly regarding parking violations and property values in Philadelphia.
src/
├── common/
│ ├── ParkingViolation.java # Data model for parking violations
│ └── Property.java # Data model for properties
├── datamanagement/
│ ├── ParkingViolationReader.java # Reads parking violations from CSV/JSON
│ ├── PropertyReader.java # Reads property data from CSV
│ └── PopulationReader.java # Reads population data
├── processor/
│ ├── DataProcessor.java # Performs calculations and data processing
│ └── ViolationList.java # Iterator implementation for violations
└── presentation/
└── Main.java # Main entry point with menu system
The following UML class diagram shows the structure and relationships between all classes in the system:
This diagram shows a layered Java application organized into four packages: common, datamanagement, processor, and presentation. The common package contains the domain model classes ParkingViolation and Property, which are simple data holders with validation methods. The datamanagement package provides reader classes (ParkingViolationReader, PropertyReader, and PopulationReader) responsible for loading raw data from CSV/JSON files and constructing the corresponding domain objects or population map. The processor package contains ViolationList, an iterator wrapper over a list of ParkingViolation objects, and DataProcessor, a singleton class that aggregates violations, properties, and population data and exposes all core computation methods (e.g., fines per capita, averages, etc.). ViolationList implements the Iterator<ParkingViolation> interface and is used internally by DataProcessor to traverse violations. Finally, the presentation package contains the Main class, which serves as the program’s entry point: it invokes the reader classes to load data, initializes the DataProcessor singleton, and drives the menu-based user interface that calls the appropriate processing methods.
- Java 8 or higher
- JSON.simple library (json-simple-1.1.1.jar)
-
The JSON.simple library
json-simple-1.1.1.jaris already included in the lib/ directory. -
Create a folder named data/ in root directory. Download sample data input files and save them in data/.
-
Compile the Java files:
mkdir -p bin javac -d bin -sourcepath src -cp ".:lib/json-simple-1.1.1.jar" \ src/common/*.java \ src/datamanagement/*.java \ src/processor/*.java \ src/presentation/*.java
-
Run the program:
java -cp ".:bin:lib/json-simple-1.1.1.jar" presentation.Main <format> <parking_file> <properties_file> <population_file>
CSV Example:
java -cp ".:bin:lib/json-simple-1.1.1.jar" presentation.Main csv data/parking.csv data/properties.csv data/population.txtOr with JSON format:
java -cp ".:bin:lib/json-simple-1.1.1.jar" presentation.Main json data/parking.json data/properties.csv data/population.txt
The program requires exactly 4 arguments (in order):
- Format: Either
csvorjson(case-sensitive) - specifies the format of the parking violations file - Parking file: Path to the parking violations file (CSV or JSON)
- Properties file: Path to the properties CSV file
- Population file: Path to the population text file
The application provides a menu-driven interface with the following options:
- Total population for all ZIP codes - Displays the sum of all populations
- Fines per capita for each ZIP code - Shows parking fines per person for each ZIP code (only PA violations)
- Average residential market value - Calculates average property value for a specified ZIP code
- Average residential total livable area - Calculates average square footage for a specified ZIP code
- Residential market value per capita - Calculates total property value divided by population for a ZIP code
- Exit - Terminates the program
After starting the program with valid arguments, you will see the main menu. The program uses a menu-driven interface where you select options by entering numbers.
The main menu displays the following options:
Main Menu:
1. Total population for all ZIP codes
2. Fines per capita for each ZIP code
3. Average residential market value for a ZIP code
4. Average residential total livable area for a ZIP code
5. Residential market value per capita for a ZIP code
0. Exit
Enter your choice:
Input: Enter a number (0-5) corresponding to your desired option.
Output: The menu will be displayed again after each operation completes.
Input: Enter 1 when prompted at the main menu.
Expected Output:
Total population for all ZIP codes: 1526206
Input: Enter 2 when prompted at the main menu.
Expected Output:
19103 0.0284
19104 0.0312
...
The output displays:
- One ZIP code per line
- ZIP code in ascending numerical order
- Fines per capita formatted to 4 decimal places
- Only ZIP codes with non-zero fines and population
Notes for Option 3-5:
- The program accepts multiple ZIP codes separated by commas
- ZIP codes are automatically normalized to their first 5 digits
- If a ZIP code has no residences, the value displayed will be 0
- Invalid market values (missing, non-numeric, negative, or zero) are ignored
Input:
- Enter
3when prompted at the main menu. - When prompted "Enter ZIP codes separated by commas (e.g., 19103,19104):", enter one or more ZIP codes separated by commas.
Example Input: 19103 or multiple codes like 19103,19104
Expected Output (single ZIP code):
ZIP 19103: Average residential market value: 2015974
Expected Output (multiple ZIP codes):
ZIP 19103: Average residential market value: 2015974
ZIP 19104: Average residential market value: 922763
Input:
- Enter
4when prompted at the main menu. - When prompted "Enter ZIP codes separated by commas (e.g., 19103,19104):", enter one or more ZIP codes separated by commas.
Example Input: 19103 or multiple codes like 19103,19104
Expected Output (single ZIP code):
ZIP 19103: Average residential total livable area: 7837
Expected Output (multiple ZIP codes):
ZIP 19103: Average residential total livable area: 7837
ZIP 19104: Average residential total livable area: 6361
Input:
- Enter
5when prompted at the main menu. - When prompted "Enter ZIP codes separated by commas (e.g., 19103,19104):", enter one or more ZIP codes separated by commas.
Example Input: 19103 or multiple codes like 19103,19104
Expected Output (single ZIP code):
ZIP 19103: Residential market value per capita: 717020
Expected Output (multiple ZIP codes):
ZIP 19103: Residential market value per capita: 717020
ZIP 19104: Residential market value per capita: 209994
Input: Enter 0 when prompted at the main menu.
Expected Output:
Exiting program. Goodbye!
The program will then terminate.
- If you enter a non-integer value at the main menu, the menu will be displayed again
- If you enter an invalid menu option (not 0-5), the menu will be displayed again
- Invalid ZIP code inputs will result in a value of 0 being displayed (for options 3, 4, and 5)









