🌿 Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms"

Hey everyone! Today, I’m back with a different kind of project—one that’s both fun and practical. We’re going to build a Simple Banking System in C++!
With this program, users can:
✔ Deposit money into their accounts
✔ Withdraw money with balance validation
✔ Check their account balance regularly
This will be a great way to apply essential C++ concepts while learning how banking systems function at a fundamental level. So, let’s dive in and code this project together!
✅ Functions – Modularizing the code for deposit, withdrawal, and balance checking.
✅ Loops – Enabling repeated user interaction through a menu system.
✅ Conditional Statements – Validating withdrawals and ensuring sufficient funds.
✅ Reference Parameters – Using &
to modify the balance in deposit and withdrawal functions.
✅ Validation – Ensuring all transactions use positive numbers and maintain a sufficient balance.
#include <iostream>
#include <iomanip> // For currency formatting
using namespace std;
// Function prototypes
void deposit(double &balance);
void withdraw(double &balance);
void checkBalance(const double &balance);
void displayMenu();
int main() {
double balance = 0.0; // Initial balance
int choice;
cout << "Welcome to the Simple Banking System!\n";
// Main loop
do {
displayMenu();
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
deposit(balance);
break;
case 2:
withdraw(balance);
break;
case 3:
checkBalance(balance);
break;
case 4:
cout << "Thank you for using the banking system. Goodbye!\n";
break;
default:
cout << "Invalid choice. Please try again.\n";
}
} while (choice != 4);
return 0;
}
// Function to display the menu
void displayMenu() {
cout << "\nMenu:\n";
cout << "1. Deposit Money\n";
cout << "2. Withdraw Money\n";
cout << "3. Check Balance\n";
cout << "4. Exit\n";
}
// Function to deposit money
void deposit(double &balance) {
double amount;
cout << "Enter the amount to deposit: ";
cin >> amount;
if (amount > 0) {
balance += amount;
cout << fixed << setprecision(2);
cout << "Successfully deposited $" << amount << ". New balance: $" << balance << ".\n";
} else {
cout << "Invalid amount. Deposit must be positive.\n";
}
}
// Function to withdraw money
void withdraw(double &balance) {
double amount;
cout << "Enter the amount to withdraw: ";
cin >> amount;
if (amount > 0) {
if (amount <= balance) {
balance -= amount;
cout << fixed << setprecision(2);
cout << "Successfully withdrew $" << amount << ". New balance: $" << balance << ".\n";
} else {
cout << "Insufficient funds. Current balance: $" << fixed << setprecision(2) << balance << ".\n";
}
} else {
cout << "Invalid amount. Withdrawal must be positive.\n";
}
}
// Function to check balance
void checkBalance(const double &balance) {
cout << fixed << setprecision(2);
cout << "Current balance: $" << balance << ".\n";
}
deposit(double &balance)
– Adds money to the account, ensuring the amount is positive.withdraw(double &balance)
– Deducts money while ensuring sufficient funds are available.checkBalance(const double &balance)
– Displays the user's current balance.do-while loop
– Ensures the menu keeps appearing until the user chooses to exit.switch
statements – Manages program flow based on user input.Welcome to the Simple Banking System!
Menu:
1. Deposit Money
2. Withdraw Money
3. Check Balance
4. Exit
Enter your choice: 1
Enter the amount to deposit: 1000
Successfully deposited $1000.00. New balance: $1000.00.
Menu:
1. Deposit Money
2. Withdraw Money
3. Check Balance
4. Exit
Enter your choice: 2
Enter the amount to withdraw: 500
Successfully withdrew $500.00. New balance: $500.00.
Menu:
1. Deposit Money
2. Withdraw Money
3. Check Balance
4. Exit
Enter your choice: 3
Current balance: $500.00.
Menu:
1. Deposit Money
2. Withdraw Money
3. Check Balance
4. Exit
Enter your choice: 4
Thank you for using the banking system. Goodbye!
Most modern banking apps follow similar logic to allow customers to deposit, withdraw, and check their balances. This project provides a fundamental understanding of how digital banking works.
ATMs operate similarly—users interact with a menu, select options, and receive validation to ensure successful transactions.
Many small businesses use simple banking software to track cash flow, income, and expenses. This project gives insights into building such systems.
A fintech firm needed to develop a digital wallet that allowed users to:
✔ Deposit money from their bank accounts
✔ Withdraw and spend money
✔ Prevent negative balances
✅ Preventing Negative Balances
✅ Ensuring Transaction Security
✅ Efficient Transaction Processing
✔ Used double
for precise decimal handling.
✔ Added additional checks to prevent integer overflow.
✔ Encrypted sensitive transaction and balance data.
✔ Implemented two-factor authentication (2FA) for withdrawals.
✔ Enabled multi-user system support.
This Simple Banking System is an excellent beginner-friendly project that teaches fundamental C++ concepts while simulating real-world banking applications.
I hope you enjoyed this project! Stay tuned for more exciting C++ mini-projects. Let me know in the comments if you have any questions or ideas for improvements. Happy coding!
Comments
Post a Comment