11# Java Advanced: Exception Handling & Collections
22
3-
4-
53![ Build Status] ( https://img.shields.io/badge/build-passing-brightgreen )
64![ License] ( https://img.shields.io/badge/License-MIT-yellow.svg )
75![ Java] ( https://img.shields.io/badge/Java-100%25-orange )
86![ Repo Size] ( https://img.shields.io/github/repo-size/TheComputationalCore/java-advanced-exceptions-collections )
97
10- </div >
11-
128---
139
14- ## 📌 Overview
10+ ## 🚀 Overview
1511
16- This repository contains ** advanced Java programs ** demonstrating :
12+ This repository contains ** advanced Java exercises (Q1–Q5) ** focusing on :
1713
1814- Custom Exception Handling
19- - Collections Framework
2015- Input Validation
21- - Stack Implementation
22- - HashMap Operations
16+ - Java Collections Framework
17+ - HashMap operations
18+ - Stack implementation
19+ - User‑driven logic & error handling
20+
21+ All tasks include ** screenshots** , ** organized source code** , and a ** fully automated CI workflow** .
22+
23+ ---
24+
25+ ## 📁 Project Structure
26+
27+ ```
28+ java-advanced-exceptions-collections/
29+ │
30+ ├── .github/workflows/
31+ │ └── java-build.yml
32+ │
33+ ├── screenshots/
34+ │ ├── 1.a.png
35+ │ ├── 1.b.png
36+ │ ├── 1.c.png
37+ │ ├── 1.d.png
38+ │ ├── 2.a.png
39+ │ ├── 2.b.png
40+ │ ├── 3.a.png
41+ │ ├── 3.b.png
42+ │ ├── 3.c.png
43+ │ ├── 4.a.png
44+ │ ├── 4.b.png
45+ │ ├── 4.c.png
46+ │ ├── 4.d.png
47+ │ └── 5.png
48+ │
49+ ├── src/
50+ │ ├── AgeNotWithinRangeException.java
51+ │ ├── NameNotValidException.java
52+ │ ├── Student.java
53+ │ ├── Voter.java
54+ │ ├── QuestionThree.java
55+ │ ├── QuestionFour.java
56+ │ ├── QuestionFive.java
57+ │ └── (supporting logic)
58+ │
59+ ├── LICENSE
60+ └── README.md
61+ ```
2362
24- It includes ** five structured tasks (Q1–Q5)** supported by screenshots and organized code.
63+ ---
64+
65+ ## 🧠 Task Breakdown
66+
67+ ### ** Q1 — Student Class with Custom Exceptions**
68+ Validates:
69+ - Age must be ** between 15–21**
70+ - Name must * not* contain numbers or special symbols
71+
72+ Uses two custom exceptions:
73+ - ` AgeNotWithinRangeException `
74+ - ` NameNotValidException `
2575
2676---
2777
28- ## 🗂️ Project Structure
78+ ### ** Q2 — Voter Age Validation**
79+ Ensures:
80+ - Age ≥ 18
81+ Else throws ** Invalid Age Exception** .
82+
83+ ---
2984
30- | File | Description |
31- | ------| -------------|
32- | ` Student.java ` | Student class with age + name validation using custom exceptions (Q1) |
33- | ` AgeNotWithinRangeException.java ` | Thrown when age is outside 15–21 (Q1) |
34- | ` NameNotValidException.java ` | Thrown when name contains invalid characters (Q1) |
35- | ` Voter.java ` | Validates voter age (must be ≥ 18) (Q2) |
36- | ` QuestionThree.java ` | Weekday array with index validation (Q3) |
37- | ` QuestionFour.java ` | Student grades using HashMap (Q4) |
38- | ` QuestionFive.java ` | Stack implementation using Collections (Q5) |
39- | ` screenshots/ ` | Complete screenshots of implementations |
85+ ### ** Q3 — Weekday Array Handling**
86+ - Takes a day index as input
87+ - Prints weekday name
88+ - Handles:
89+ - Invalid numeric input
90+ - Array out‑of‑bounds cases
4091
4192---
4293
43- ## 🖼️ Screenshots (Grid View)
94+ ### ** Q4 — Student Grades Using HashMap**
95+ Supports:
96+ - Add student + grade
97+ - Remove student
98+ - Fetch grade
99+
100+ Uses:
101+ ``` java
102+ HashMap<String , Integer >
103+ ```
104+
105+ ---
106+
107+ ### ** Q5 — Stack Implementation (Collections)**
108+ Operations:
109+ - ` push() `
110+ - ` pop() `
111+ - ` isEmpty() `
112+
113+ Uses:
114+ ``` java
115+ Stack<Integer >
116+ ```
44117
45- ### ** Q1 — Student Management (Exceptions)**
118+ ---
119+
120+ ## 🖼️ Screenshots (Grid Layout)
121+
122+ ### ** Q1 — Student Management**
46123<table >
47124<tr >
48- <td ><img src =" screenshots/1.a.png " width =" 250 " ></td >
49- <td ><img src =" screenshots/1.b.png " width =" 250 " ></td >
125+ <td ><img src =" screenshots/1.a.png " width =" 260 " ></td >
126+ <td ><img src =" screenshots/1.b.png " width =" 260 " ></td >
50127</tr >
51128<tr >
52- <td ><img src =" screenshots/1.c.png " width =" 250 " ></td >
53- <td ><img src =" screenshots/1.d.png " width =" 250 " ></td >
129+ <td ><img src =" screenshots/1.c.png " width =" 260 " ></td >
130+ <td ><img src =" screenshots/1.d.png " width =" 260 " ></td >
54131</tr >
55132</table >
56133
@@ -59,120 +136,76 @@ It includes **five structured tasks (Q1–Q5)** supported by screenshots and org
59136### ** Q2 — Voter Age Validation**
60137<table >
61138<tr >
62- <td ><img src =" screenshots/2.a.png " width =" 250 " ></td >
63- <td ><img src =" screenshots/2.b.png " width =" 250 " ></td >
139+ <td ><img src =" screenshots/2.a.png " width =" 260 " ></td >
140+ <td ><img src =" screenshots/2.b.png " width =" 260 " ></td >
64141</tr >
65142</table >
66143
67144---
68145
69- ### ** Q3 — Weekday Array Handling **
146+ ### ** Q3 — Weekday Array**
70147<table >
71148<tr >
72- <td ><img src =" screenshots/3.a.png " width =" 250 " ></td >
73- <td ><img src =" screenshots/3.b.png " width =" 250 " ></td >
74- <td ><img src =" screenshots/3.c.png " width =" 250 " ></td >
149+ <td ><img src =" screenshots/3.a.png " width =" 260 " ></td >
150+ <td ><img src =" screenshots/3.b.png " width =" 260 " ></td >
151+ <td ><img src =" screenshots/3.c.png " width =" 260 " ></td >
75152</tr >
76153</table >
77154
78155---
79156
80- ### ** Q4 — Student Grades (HashMap) **
157+ ### ** Q4 — HashMap Grades**
81158<table >
82159<tr >
83- <td ><img src =" screenshots/4.a.png " width =" 250 " ></td >
84- <td ><img src =" screenshots/4.b.png " width =" 250 " ></td >
160+ <td ><img src =" screenshots/4.a.png " width =" 260 " ></td >
161+ <td ><img src =" screenshots/4.b.png " width =" 260 " ></td >
85162</tr >
86163<tr >
87- <td ><img src =" screenshots/4.c.png " width =" 250 " ></td >
88- <td ><img src =" screenshots/4.d.png " width =" 250 " ></td >
164+ <td ><img src =" screenshots/4.c.png " width =" 260 " ></td >
165+ <td ><img src =" screenshots/4.d.png " width =" 260 " ></td >
89166</tr >
90167</table >
91168
92169---
93170
94- ### ** Q5 — Stack Implementation**
95- <img src =" screenshots/5.png " width =" 300 " >
96-
97- ---
98-
99- ## 🧠 Task Breakdown
100-
101- ### ** Q1 — Custom Exceptions in Student Class**
102- - Validates:
103- - Age between ** 15–21**
104- - Name must NOT contain digits or symbols
105- - Uses two custom exceptions:
106- - ` AgeNotWithinRangeException `
107- - ` NameNotValidException `
108-
109- ---
110-
111- ### ** Q2 — Voter Age Validation**
112- Ensures voter age is ** ≥ 18** , otherwise throws a custom exception.
113-
114- ---
115-
116- ### ** Q3 — Weekday Array**
117- - Stores weekday names in an array.
118- - Handles:
119- - Invalid index
120- - ` ArrayIndexOutOfBoundsException `
171+ ### ** Q5 — Stack**
172+ <img src =" screenshots/5.png " width =" 320 " >
121173
122174---
123175
124- ### ** Q4 — Student Grades (HashMap)**
125- Operations:
126- - Add student + grade
127- - Remove student
128- - Print grade by name
176+ ## ▶️ How to Run
129177
130- Uses:
131- ``` java
132- HashMap< String , Integer >
178+ ### Clone
179+ ``` bash
180+ git clone https://github.com/TheComputationalCore/java-advanced-exceptions-collections.git
133181```
134182
135- ---
183+ ### Navigate
184+ ``` bash
185+ cd java-advanced-exceptions-collections/src
186+ ```
136187
137- ### ** Q5 — Integer Stack (Collections)**
138- Implements:
139- - ` push() `
140- - ` pop() `
141- - ` isEmpty() `
188+ ### Compile Everything
189+ ``` bash
190+ javac * .java
191+ ```
142192
143- Uses:
144- ``` java
145- Stack<Integer >
193+ ### Run Any Task
194+ ``` bash
195+ java Student # Q1
196+ java Voter # Q2
197+ java QuestionThree # Q3
198+ java QuestionFour # Q4
199+ java QuestionFive # Q5
146200```
147201
148202---
149203
150- ## ▶️ How to Run
151-
152- 1 . ** Clone the Repository** :
153- ``` bash
154- git clone https://github.com/TheComputationalCore/java-advanced-exceptions-collections.git
155- ```
156- 2 . ** Navigate to the Project Directory** :
157- ``` bash
158- cd java-advanced-exceptions-collections
159- ```
160- 3 . ** Compile the Java Files** :
161- ``` bash
162- javac * .java
163- ```
164- 4. ** Run the Desired Program** :
165- ` ` ` bash
166- ' java Student' # Q1
167- 'java Voter' # Q2
168- 'java QuestionThree' # Q3
169- 'java QuestionFour' # Q4
170- 'java QuestionFive' # Q5
171- ` ` `
204+ ## 📜 License
205+ Distributed under the ** MIT License** .
172206
173207---
174208
175- # # 📄 License
176-
177- This project is licensed under the ** MIT License** .
209+ ## ⭐ Contribution
210+ Feel free to open PRs, file issues, or suggest improvements!
178211
0 commit comments