All Projects

Bus Ticket Booking System in Python
Bus Ticket Booking System in Java
Bus Ticket Booking System in Cpp
Bus Ticket Booking System in C
Cafe Order System in Python
Cafe Order System in Java
Cafe Order System in Cpp
Cafe Order System in C
Social Media Account Details Manager in Python
Social Media Account Details Manager in Java
Social Media Account Details Manager in Cpp
Social Media Account Details Manager in C
Mini ATM in Python Language
Mini ATM in Java Language
Mini ATM in cpp language
Mini ATM in c language
Pocket Money Manager in Python Language
Pocket Money Manager in Java Language
Pocket Money Manager in Cpp Language
Pocket Money Manager in C Language
Username Password Generator in Python Language
Username Password Generator in Cpp Language
Username Password Generator in C Language
Telephone Directory in Python Language
Telephone Directory in Java Language
Telephone Directory in Cpp Language
Telephone Directory in C Language
Calander in Cpp Language
Calander in C Language
NoteBook in Python Language
NoteBook in Cpp Language
NoteBook in C Language
Voting System in Python Language
Voting System in Java Language
Voting System in Cpp Language
Voting System in C Language
Age Calculator in Python Language
Age Calculator in Java Language
Age Calculator in Cpp Language
Age Calculator in C Language
Currency Converter in Python Language
Currency Converter in Java Language
Currency Converter in Cpp Language
Currency Converter in C Language
Random Password Generator in python language
Random Password Generator in java language
Random Password Generator in cpp language
Random Password Generator in c language
Billing System in python language
Billing System in c++ language
Billing System in c language
Atm in c language

Pocket Money Manager in Cpp Language


Aniket The Programmer

1.22K+ Subscribers

Click To Subscribe My Channel

Subscribe

Source Code

        
#include <iostream>
#include <string>
#include <ctime>
#include <vector>
using namespace std;

struct Transaction {
    string description;
    float amount;
};

class PocketMoney {
private:
    float budget;
    float expenses;
    float savings;
    vector<Transaction> transactions;

public:
    PocketMoney() {
        budget = 0.0;
        expenses = 0.0;
        savings = 0.0;
    }

    void initialize() {
        cout << "Enter your budget for the month: ";
        cin >> budget;
    }

    void spend() {
        float amount;
        cout << "Enter amount spent: ";
        cin >> amount;

        if (amount <= budget - expenses) {
            expenses += amount;
            cout << "Expense recorded." << endl;

            Transaction transaction;
            cin.ignore(); // Clear newline from buffer
            cout << "Enter a brief description for this expense: ";
            getline(cin, transaction.description);
            transaction.amount = amount;
            transactions.push_back(transaction);
        } else {
            cout << "Exceeds the budget! Cannot spend more." << endl;
        }
    }

    void save() {
        float amount;
        cout << "Enter amount saved: ";
        cin >> amount;

        if (amount <= expenses) {
            savings += amount;
            expenses -= amount;
            cout << "Savings recorded." << endl;

            Transaction transaction;
            cin.ignore(); // Clear newline from buffer
            cout << "Enter a brief description for this savings: ";
            getline(cin, transaction.description);
            transaction.amount = -amount; // Negative amount denotes savings
            transactions.push_back(transaction);
        } else {
            cout << "Cannot save more than expenses!" << endl;
        }
    }

    void display() {
        cout << "Pocket Money Management:" << endl;
        cout << "----------------------------" << endl;
        cout << "Budget: " << budget << endl;
        cout << "Expenses: " << expenses << endl;
        cout << "Savings: " << savings << endl;
        cout << "----------------------------" << endl;
    }

    void showTransactions() {
        cout << "Transactions History:" << endl;
        cout << "----------------------------" << endl;
        for (const auto& transaction : transactions) {
            cout << "Description: " << transaction.description << "  Amount: " << transaction.amount << endl;
        }
        cout << "----------------------------" << endl;
    }

    void setReminder() {
        time_t now = time(0);
        tm endOfMonth = *localtime(&now);

        endOfMonth.tm_mon += 1; // Increase month by 1
        endOfMonth.tm_mday = 1; // Set day to the first day of next month
        endOfMonth.tm_hour = 0; // Set time to midnight
        endOfMonth.tm_min = 0;
        endOfMonth.tm_sec = 0;

        mktime(&endOfMonth); // Normalize the time structure

        cout << "Reminder: Reset the budget by the end of the month!" << endl;
        cout << "The end of the month is on: " << asctime(&endOfMonth);
    }
};

int main() {
    PocketMoney pocket;
    int choice;

    pocket.initialize();

    do {
        cout << "Pocket Money Menu:" << endl;
        cout << "1. Spend Money" << endl;
        cout << "2. Save Money" << endl;
        cout << "3. Display Details" << endl;
        cout << "4. Show Transactions" << endl;
        cout << "5. Set Reminder" << endl;
        cout << "6. Exit" << endl;
        cout << "Enter your choice: ";
        cin >> choice;

        switch (choice) {
            case 1:
                pocket.spend();
                break;
            case 2:
                pocket.save();
                break;
            case 3:
                pocket.display();
                break;
            case 4:
                pocket.showTransactions();
                break;
            case 5:
                pocket.setReminder();
                break;
            case 6:
                cout << "Exiting..." << endl;
                break;
            default:
                cout << "Invalid choice. Please enter a valid option." << endl;
        }
    } while (choice != 6);

    return 0;
}
        
    

Source Code Github Link: View

View Video On Youtube Link: View

35k+ Coding Problems: Edocgram is collection of 35k+ coding problems Edocgram! 🎉