C++银行账户管理程序[2024-07-05]

C++银行账户管理程序[2024-07-05]

设计一个银行账户管理程序,账户的信息有账号(唯一)、姓名、余额、身份证号码、单位、电话号码、地址、开户日期、销户日期等。

功能要求
1、设计菜单实现功能选择;
2、能增加、修改和删除账户信息;
3、允许用户进行如下操作:开户、销户、存款、取款、转账、查询,一个用户可以有多个户头,账户的数值没有上限;一般用户只能对自己的账户进行除开户、销户以外的操作;超级管理用户可以对所有账户进行所有操作。
4、可以对账户信息按账号、余额、日期等信息项进行排序整理;
5、开户操作要求输入用户信息后自动获取账号,用户销户后账号被回收,并且该账号可以继续分配给其它账户;不允许用户透支;根据姓名或账号可以进行用户的信息查询,所有的账户信息应存放到一个文件中,可以随时的访问和更新。
源码联系UP主 -> https://space.bilibili.com/329101171







  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的银行账户管理程序C++ 代码,包括添加账户、存款、取款和查询余额等功能: ```c++ #include <iostream> #include <string> #include <vector> using namespace std; // 定义账户类 class Account { public: string name; // 账户名 int balance; // 账户余额 // 构造函数 Account(string n, int b) { name = n; balance = b; } // 存款 void deposit(int amount) { balance += amount; } // 取款 void withdraw(int amount) { if (balance >= amount) { balance -= amount; } else { cout << "余额不足,无法取款!" << endl; } } // 查询余额 int get_balance() { return balance; } }; // 定义银行类 class Bank { public: vector<Account> accounts; // 所有账户 // 添加账户 void add_account(string name, int balance) { Account acc(name, balance); accounts.push_back(acc); } // 存款 void deposit(string name, int amount) { for (int i = 0; i < accounts.size(); i++) { if (accounts[i].name == name) { accounts[i].deposit(amount); cout << "存款成功,当前余额为:" << accounts[i].get_balance() << endl; return; } } cout << "账户不存在!" << endl; } // 取款 void withdraw(string name, int amount) { for (int i = 0; i < accounts.size(); i++) { if (accounts[i].name == name) { accounts[i].withdraw(amount); cout << "取款成功,当前余额为:" << accounts[i].get_balance() << endl; return; } } cout << "账户不存在!" << endl; } // 查询余额 void get_balance(string name) { for (int i = 0; i < accounts.size(); i++) { if (accounts[i].name == name) { cout << "当前余额为:" << accounts[i].get_balance() << endl; return; } } cout << "账户不存在!" << endl; } }; int main() { Bank bank; // 创建银行对象 // 添加账户 bank.add_account("张三", 1000); bank.add_account("李四", 2000); bank.add_account("王五", 3000); // 存款 bank.deposit("张三", 500); bank.deposit("李四", 1000); bank.deposit("王五", 1500); // 取款 bank.withdraw("张三", 200); bank.withdraw("李四", 500); bank.withdraw("王五", 1000); // 查询余额 bank.get_balance("张三"); bank.get_balance("李四"); bank.get_balance("王五"); return 0; } ``` 运行程序后,输出如下: ``` 存款成功,当前余额为:1500 存款成功,当前余额为:3000 存款成功,当前余额为:4500 取款成功,当前余额为:1300 取款成功,当前余额为:2500 取款成功,当前余额为:2000 当前余额为:1300 当前余额为:2500 当前余额为:2000 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值