0% found this document useful (0 votes)
11 views16 pages

Albeta Thomas

Uploaded by

abenizanwonu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views16 pages

Albeta Thomas

Uploaded by

abenizanwonu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

FEDERAL UNIVERSITY OF KASHERE,

P.M. BOX 0182 GOMBE STATE.

FACULTY OF SCIENCE

DEPARTMENT OF COMPUTER SCIENCE

ASSIGNMENT

COURSE CODE: CSC 2304

COURSE TITTLE: FUNDAMENTAL OF DATA STRUCTURE

ID NUMBER: GROUP NINE (9)

QUESTION: CREATE A SYSTEM TO MANAGE PERSONAL FINANCES,

INCLUDING TRACKING EXPENSES, INCOME AND BUDGETTING,

USING STACK DATA STRUCTURE.

COURSE LECTURER

MR. JEREMIAH ISUWA

JUNE, 2024.

1|Page
TABLE OF CONTENTS
CHAPTER 1................................................................................................................................3
1.0 ABSTRACT.......................................................................................................................3
1.2 INTRODUCTION............................................................................................................3
1.3 PREFERENCES...............................................................................................................3
CHAPTER 2................................................................................................................................4
2.0 MAIN PROJECT STRUCTURE.......................................................................................4
2.1 MAIN SYSTEM BUILDING ON A JAVA IDE VIEW (PYCHAM)................................4
2.2 OUTPUT...........................................................................................................................6
2.3 FEATURES......................................................................................................................6
2.4 How it is run.......................................................................................................................6
2.5 PSEODECODE FOR THE PROGRAM........................................................................6
2.6 ALGORITHM..................................................................................................................8
2.7 FLOWCHART FOR THE PROGRAM.........................................................................8
CHAPTER 3...............................................................................................................................9
3.0 SUMMARY......................................................................................................................9
3.1 Here is a summary that includes the stack data structure:...........................................9
3.1.1 FUNCTIONAL REQUIREMENTS.............................................................................9
4.0 NON-FUNCTIONAL REQUIREMENTS......................................................................9
5.0 ADDITIONAL CONSIDERATIONS.............................................................................9
6.0 CONCLUSION...............................................................................................................10
6.1 Key Takeaways:..............................................................................................................10
6.2 Future Enhancements:...................................................................................................10
CHAPTER 5..............................................................................................................................11
7.0 REFERENCES...............................................................................................................11

2|Page
CHAPTER 1

1.0 ABSTRACT

This project develops a personal finance management system using Python. The system

allows users to add expenses and income, view transactions, calculate totals, and check

budget status. The project aims to provide a simple and effective tool for individuals to

manage their finances efficiently.

1.2 INTRODUCTION

In today's complex financial landscape, effective personal finance management is

crucial for achieving financial stability and growth, our (Personal Finance Management

System) is designed to empower individuals to take control of their finances by

providing an intuitive and efficient way to track income, manage expenses, and adhere

to budgets.

Using a stack-based data structure, this system offers a robust approach to handling

financial transactions in a Last-In-First-Out (LIFO) manner. This design ensures

simplicity in adding and reviewing transactions while maintaining the flexibility to

revert the most recent changes, reflecting real-life scenarios where recent financial

decisions often need quick revisiting or correction.

1.3 PREFERENCES

 Programming language: Python

 Data Structure: Stack Data Structure

 User interface: Command-line interface (CLI)

3|Page
CHAPTER 2

2.0 MAIN PROJECT STRUCTURE

2.1 MAIN SYSTEM BUILDING ON A JAVA IDE VIEW (PYCHAM)

from datetime import datetime

class Stack:

def __init__(self):

self.items = []

def push(self, item):

self.items.append(item)

def pop(self):

return self.items.pop() if not self.is_empty() else None

def is_empty(self):

return len(self.items) == 0

def peek(self):

return self.items[-1] if not self.is_empty() else None

def validate_date(date_string):

try:

datetime.strptime(date_string, '%Y-%m-%d')

return True

except ValueError:

4|Page
return False

def calculate_total(stack):

total = 0

for item in stack.items:

total += item['amount']

return total

def main():

expenses_stack = Stack()

income_stack = Stack()

while True:

print("\nPERSONAL FINANCE MANAGEMENT SYSTEM")

print("1. Add Expense")

print("2. Add Income")

print("3. View Expenses")

print("4. View Income")

print("5. View Total Expenses")

print("6. View Total Income")

print("7. View Budget Status")

print("8. Exit")

choice = input("Enter your choice: ")

if choice == '1':

amount = float(input("Enter amount spent: "))

category = input("Enter category: ")

description = input("Enter description: ")

date = input("Enter date (YYYY-MM-DD): ")

5|Page
if validate_date(date):

expenses_stack.push({'amount': amount, 'category': category, 'description':

description, 'date': date})

print("Expense added successfully!")

else:

print("Invalid date format. Please use YYYY-MM-DD.")

elif choice == '2':

amount = float(input("Enter amount earned: "))

source = input("Enter income source: ")

description = input("Enter description: ")

date = input("Enter date (YYYY-MM-DD): ")

if validate_date(date):

income_stack.push({'amount': amount, 'source': source, 'description':

description, 'date': date})

print("Income added successfully!")

else:

print("Invalid date format. Please use YYYY-MM-DD.")

elif choice == '3':

if expenses_stack.is_empty():

print("No expenses found.")

else:

print("\nAll Expenses:")

for item in expenses_stack.items:

print(

f"Amount: ${item['amount']}, Category: {item['category']}, Description:

6|Page
{item['description']}, Date: {item['date']}")

elif choice == '4':

if income_stack.is_empty():

print("No income found.")

else:

print("\nAll Income:")

for item in income_stack.items:

print(

f"Amount: ${item['amount']}, Source: {item['source']}, Description:

{item['description']}, Date: {item['date']}")

elif choice == '5':

total_expenses = calculate_total(expenses_stack)

print(f"\nTotal Expenses: ${total_expenses}")

elif choice == '6':

total_income = calculate_total(income_stack)

print(f"\nTotal Income: ${total_income}")

elif choice == '7':

total_income = calculate_total(income_stack)

total_expenses = calculate_total(expenses_stack)

if total_income > total_expenses:

print(f"\nBudget status: Surplus of ${total_income - total_expenses}")

elif total_income < total_expenses:

print(f"\nBudget status: Deficit of ${total_expenses - total_income}")

else:

print("\nBudget status: Balanced")

7|Page
elif choice == '8':

print("Exiting the program. Goodbye!")

break

else:

print("Invalid choice. Please try again.")

if __name__ == "__main__":

main()

2.2 OUTPUT

2.3 FEATURES

 Add and view expenses

 Add and view income

 Calculate total expenses and income

 Check budget status (surplus, deficit, balanced)

2.4 How it is run

 we ensure we have Python installed on your system.

 Download the script.

 We then navigate to the directory containing `finance_manager.py`.

 Now we run the script using the command:

8|Page
2.5 PSEODECODE FOR THE PROGRAM

expenses_stack = Stack()

income_stack = Stack()

function validate_date(date_string):

try:

datetime.strptime(date_string, '%Y-%m-%d')

return True

except ValueError:

return False

function calculate_total(stack):

total = 0

for item in stack.items:

total += item['amount']

return total

function main():

while True:

choice = input("Enter choice (1-8): ")

if choice == '1' or choice == '2': # Add Expense/Income

# Get user input and validate date

if validate_date(date):

9|Page
stack.push(user_input)

print("Record added successfully!")

else:

print("Invalid date format.")

elif choice == '3' or choice == '4': # View Expenses/Income

if stack.is_empty():

print("No records found.")

else:

print("\nAll Records:")

for item in stack.items:

print(item)

elif choice == '5' or choice == '6': # View Total Expenses/Income

total = calculate_total(stack)

print(f"\nTotal: ${total}")

elif choice == '7': # View Budget Status

total_income = calculate_total(income_stack)

total_expenses = calculate_total(expenses_stack)

# Calculate and print budget status

elif choice == '8': # Exit

print("Exiting the program. Goodbye!")

10 | P a g e
break

else:

print("Invalid choice. Please try again.")

2.6 ALGORITHM

1. Initialize two stacks, expenses stack and income stack, to store expense and income

records, respectively.

2. Define a function, validate date, to check if a date string is in the correct format

(YYYY-MM-DD).

3. Define a function, calculate total, to calculate the total amount in a stack.

4. In the main function:

- Display a menu for the user to choose from.

- Based on the user's choice:

- Add an expense or income record to the respective stack.

- Validate the date format before adding the record.

- Display a success message or an error message if the date format is invalid.

- View all expenses or income records.

- Calculate and display the total expenses or income.

- Calculate and display the budget status (surplus, deficit, or balanced).

- Exit the program.

11 | P a g e
2.7 FLOWCHART FOR THE PROGRAM

CHAPTER 3

3.0 SUMMARY

3.1 Here is a summary that includes the stack data structure:

3.1.1 FUNCTIONAL REQUIREMENTS

 Add Expense (push expense onto the stack)

 Add Income (push income onto the stack)

 View Expenses (pop and display all expenses from the stack)

 View Income (pop and display all incomes from the stack)

 View Total Expenses (calculate total expenses from the stack)

 View Total Income (calculate total income from the stack)

 View Budget Status (compare total income and expenses from the stack)

12 | P a g e
 Exit Program (exit program safely)

4.0 NON-FUNCTIONAL REQUIREMENTS

 Usability (Ease of Use, Feedback)

 Performance (Responsiveness, Efficiency)

 Reliability (Accuracy, Data Integrity)

 Maintainability (Modular Design, Readability)

 Compatibility (Platform Independence, Dependency Management)

 Security (Input Validation)

 Extensibility (Future Enhancements)

5.0 ADDITIONAL CONSIDERATIONS

1. Error Handling (Invalid Input, Empty Data)

2. Documentation (User Guide, Code Comments)

3. Testing (Unit Testing, Integration Testing)

4. Data Structure (Stack data structure for storing expenses and incomes)

By using a stack data structure, the system can efficiently store and manage expenses

and incomes, and provide accurate calculations for total expenses, income, and budget

status.

13 | P a g e
CHAPTER 4

6.0 CONCLUSION

The Personal Finance Management System demonstrates an effective application of the

stack data structure for managing personal finances. By leveraging stacks, the system

provides a robust and simple method for users to track their expenses and income in a

last-in, first-out (LIFO) manner.

6.1 Key Takeaways:

1. Effective Use of Stacks: The stack data structure is ideal for managing the

addition and removal of financial records, ensuring that the most recent entries

are easily accessible.

2. User-Friendly Interface: The command-line menu allows users to interact with

the system intuitively, making financial management straightforward and

efficient.

3. Comprehensive Tracking: Users can categorize and describe their financial

transactions, and the system calculates total expenses and income, helping users

maintain a balanced budget.

6.2 Future Enhancements:

1. Data Persistence: Incorporate file-based or database storage to save stack data

between sessions.

2. Extended Functionality: Add features like undoing recent entries (using stack's

pop method), and advanced searching and sorting of financial records.

3. Graphical Interface: Develop a graphical user interface (GUI) for enhanced

usability and visualization of financial data.

This project showcases the practical application of the stack data structure in a real-

world context, highlighting its utility in managing dynamic financial data effectively. It

14 | P a g e
provides a foundation for further development into a more sophisticated personal

finance management tool.

CHAPTER 5

7.0 REFERENCES

Book:

1. -"Python Data Structures and Algorithms" by Benjamin Baka

-Description: This book provides a detailed exploration of data structures and

algorithms in Python, including stacks. It covers the implementation of various data

structures and algorithms with practical examples and use cases.

-Key Topics: Stacks, queues, linked lists, trees, sorting, searching, and algorithm

design.

Online Resources:

2. -"Problem Solving with Algorithms and Data Structures using Python" by Bradley N.

Miller and David L. Ranum

-Description: A comprehensive online textbook that covers data structures, algorithms,

and their implementations in Python. The book includes examples, visualizations, and

exercises.

-URL: [Interactive Python Textbook]

(https://runestone.academy/runestone/books/published/pythonds/index.html)

-Key Topics: Basic data structures (including stacks), recursion, algorithm efficiency,

sorting, and searching.


15 | P a g e
3. -"GeeksforGeeks: Data Structures and Algorithms in Python"

-Description: A well-organized resource with tutorials on implementing and

understanding various data structures, including stacks, in Python. It includes code

examples and explanations.

-URL: [GeeksforGeeks Python Data Structures] (https://www.geeksforgeeks.org/data-

structures-and-algorithms-in-python/)

4. Github.com

5. conversation with Microsoft copilot on 29/06/2024

6. An AI assistance

16 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy