使用类的银行管理系统的C ++程序

In this program, we are using the concept of C++ class and object, following basic operations are being performed here,

在此程序中,我们使用C ++类和对象的概念,在此执行以下基本操作,

  • Opening an account

    开户

  • Show account info

    显示帐户信息

  • Deposit

    存款

  • Withdraw

    退出

  • Search

    搜索

Note: It's a basic program just for the practice of the concept of class and object.

注意:这是一个基本程序,仅用于实现类和对象的概念。

In this program, we have created a class Bank with the following member functions,

在此程序中,我们创建了一个具有以下成员函数的Bank类,

  • OpenAccount() – It will take input account number, name and opening balance.

    OpenAccount() –将使用输入的帐号,名称和期初余额。

  • ShowAccount() – It will display the account details such as account number, name and balance.

    ShowAccount() –将显示帐户详细信息,例如帐号,名称和余额。

  • Deposit() – It will ask for the amount to be added in available balance, and deposit the amount.

    Deposit() –它将要求将金额添加到可用余额中,并存入金额。

  • Withdrawal() – It will ask for the amount to be withdrawn from the available, will also check the available balance, if balance is available, it will deduct the amount from the available balance.

    Withdrawal() –它将要求从可用金额中提取金额,还将检查可用余额,如果余额可用,则会从可用余额中扣除金额。

  • Search() – It will search for the record and display the account info.

    Search() –它将搜索记录并显示帐户信息。

银行管理系统的C ++程序 (C++ program for banking management system)

#include <iostream>
using namespace std;
// class
class Bank {
private:
int acno;
char name[30];
long balance;
public:
void OpenAccount()
{
cout << "Enter Account Number: ";
cin >> acno;
cout << "Enter Name: ";
cin >> name;
cout << "Enter  Balance: ";
cin >> balance;
}
void ShowAccount()
{
cout << "Account Number: " << acno << endl;
cout << "Name: " << name << endl;
cout << "Balance: " << balance << endl;
}
void Deposit()
{
long amt;
cout << "Enter Amount U want to deposit? ";
cin >> amt;
balance = balance + amt;
}
void Withdrawal()
{
long amt;
cout << "Enter Amount U want to withdraw? ";
cin >> amt;
if (amt <= balance)
balance = balance - amt;
else
cout << "Less Balance..." << endl;
}
int Search(int);
};
int Bank::Search(int a)
{
if (acno == a) {
ShowAccount();
return (1);
}
return (0);
}
// main code
int main()
{
Bank C[3];
int found = 0, a, ch, i;
for (i = 0; i <= 2; i++) {
C[i].OpenAccount();
}
do {
// display options
cout << "\n\n1:Display All\n2:By Account No\n3:Deposit\n4:Withdraw\n5:Exit" << endl;
// user input
cout << "Please input your choice: ";
cin >> ch;
switch (ch) {
case 1: // displating account info
for (i = 0; i <= 2; i++) {
C[i].ShowAccount();
}
break;
case 2: // searching the record
cout << "Account Number? ";
cin >> a;
for (i = 0; i <= 2; i++) {
found = C[i].Search(a);
if (found)
break;
}
if (!found)
cout << "Record Not Found" << endl;
break;
case 3: // deposit operation
cout << "Account Number To Deposit Amount? ";
cin >> a;
for (i = 0; i <= 2; i++) {
found = C[i].Search(a);
if (found) {
C[i].Deposit();
break;
}
}
if (!found)
cout << "Record Not Found" << endl;
break;
case 4: // withdraw operation
cout << "Account Number To Withdraw Amount? ";
cin >> a;
for (i = 0; i <= 2; i++) {
found = C[i].Search(a);
if (found) {
C[i].Withdrawal();
break;
}
}
if (!found)
cout << "Record Not Found" << endl;
break;
case 5: // exit
cout << "Have a nice day" << endl;
break;
default:
cout << "Wrong Option" << endl;
}
} while (ch != 5);
return 0;
}

Output

输出量

Enter Account Number: 111 
Enter Name: Shivang 
EnterBalance: 30000 
Enter Account Number: 112 
Enter Name: Radib 
EnterBalance: 20000 
Enter Account Number: 123 
Enter Name: Prem
EnterBalance: 10000 
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 1 
Account Number: 111 
Name: Shivang 
Balance: 30000
Account Number: 112 
Name: Radib 
Balance: 20000
Account Number: 123 
Name: Prem
Balance: 10000
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 2 
Account Number? 111 
Account Number: 111 
Name: Shivang 
Balance: 30000
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 3 
Account Number To Deposit Amount? 112 
Account Number: 112 
Name: Radib 
Balance: 20000
Enter Amount U want to deposit? 20000 
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 2 
Account Number? 112 
Account Number: 112 
Name: Radib 
Balance: 40000
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 4 
Account Number To Withdraw Amount? 111
Account Number: 111 
Name: Shivang 
Balance: 30000
Enter Amount U want to withdraw? 15000
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 1 
Account Number: 111 
Name: Shivang 
Balance: 15000
Account Number: 112 
Name: Radib 
Balance: 40000
Account Number: 123 
Name: Prem
Balance: 10000
1:Display All 
2:By Account No 
3:Deposit 
4:Withdraw
5:Exit
Please input your choice: 5 
Have a nice day 

翻译自: https://www.includehelp.com/cpp-programs/banking-management-system-using-class.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/545226.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2万字长文包教包会 JVM 内存结构

点击蓝色“Java中文社群”关注我哟加个“星标”&#xff0c;一起成长&#xff0c;做牛逼闪闪的技术人JVM ≠ Japanese Videos Man写这篇的主要原因呢&#xff0c;就是为了能在简历上写个“熟悉JVM底层结构”&#xff0c;另一个原因就是能让读我文章的大家也写上这句话&#xf…

vb.net 读写文件

读取和写入文件 以下示例将一行文本写入文件。 Write text to a file Sub WriteTextToFile() Dim file As New System.IO.StreamWriter("c:test.txt") file.WriteLine("Here is the first line.") file.Close() End Sub 以下示例将文件中的文本读取到…

Oracle 10g、11g :RAC关闭、启动、重启步骤

关闭顺序&#xff1a;【其他节点】-> [第一个节点]操作&#xff1a;step 1&#xff1a;{以grid用户或关闭监听&#xff1a; { crs_stop 监听器资源名 | srvctl stop listener } --全局|oracle用户关闭监听&#xff1a;{ lsnrctl stop } --单个节点}step 2&#xff1a;以orac…

虹软安卓人脸识别初学

1_下载SDK 进入虹软官网&#xff1a; 点击人脸识别SDK 进入开发者中心&#xff08;注册登录&#xff09; 新建应用并添加SDK 输入相应信息&#xff0c;确认 下载sdk 2_run示例代码注意事项 跑不起来的解决方法&#xff08;SDK版本不一致&#xff09; 3_激活并使用

css圆在中心根据宽度缩放_根据CSS中的容器宽度重新缩放字体

css圆在中心根据宽度缩放Introduction: 介绍&#xff1a; Dealing with fonts is a very interesting thing to do as fonts bring out the appearance of your website or a web page so you must choose the ideal fonts for your website or web page that helps in making…

vb.net 的 openFileDialog 控件文件筛选器使用

Filter 属性设置当前文件名筛选字符串&#xff0c;该字符串确定出现在对话框的“文件类型”框中的选项。 openFileDialog1.InitialDirectory "c:\\" ; openFileDialog1.Filter "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.Filter…

Java中不可或缺的59个小技巧,贼好用!

来源&#xff1a;https://blog.dogchao.cn/?p70《Effective JavaJava》名著&#xff0c;必读。如果能严格遵从本文的原则&#xff0c;以编写API的质量来苛求自己的代码&#xff0c;会大大提升编码素质。以下内容只记录了我自己整理的东西&#xff0c;还是建议读原文。为了聚焦…

c# contains_清单 .Contains()方法,以C#为例

c# containsC&#xff03;List <T> .Contains()方法 (C# List<T>.Contains() Method) List<T>.Contains() method is used to check whether list contains a specified element or not. List <T> .Contains()方法用于检查list是否包含指定的元素。 S…

第一次使用Sourcetree成功上传gitee记录

第一次使用Sourcetree成功上传gitee记录2_克隆gitee仓库到本地1_设置密钥公钥3_上传本地工作区进而上传到gitee4_最后一步&#xff0c;将文件从本地master提交到gitee5_小问题汇总5.1_git远端打不开5.2_当有多个仓库在使用时设置多个密钥公钥5.3_账户公钥和仓库公钥使用ssh密钥…

SUBSTR函数的使用

http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions181.htm#i87066Substr语法&#xff1a;substr函数返回字符的部分&#xff0c;从postition开始定位&#xff0c;返回可选的字符长度substring_length。substr根据char字符集的字节数来计算长度。substrb则使用位…

vb.net axWindowsMediaPlayer 控件使用

利用axWindowsMediaPlayer&#xff08;Windows Media Player&#xff09;制作MP3播放器 2 在制作mp3播放器之前&#xff0c;我们需要了解axWindowsMediaPlayer 媒体主要方法属性&#xff1a; 属性/方法名&#xff1a; 说明&#xff1a; [基本属性]   URL:String; 指定媒体位…

坑爹的 Lombok,把我害惨了!

来源&#xff1a;juejin.im/post/6881432532332576781序言去年在项目当中引入了Lombok插件&#xff0c;着实解放了双手&#xff0c;代替了一些重复的简单工作(Getter,Setter,toString等方法的编写)&#xff0c;但是&#xff0c;在使用的过程当中&#xff0c;也发现了一些坑&…

数据结构学习笔记(六)链表算法题

假期结束&#xff0c;看点题目。 第一题 问题 设顺序表用数组A[]表示&#xff0c;表中元素存储在数组下标1~mn的范围内&#xff0c;前m个元素递增有序&#xff0c;后n个元素递增有序&#xff0c;设计一个算法&#xff0c;使得整个顺序表有序。 &#xff08;1&#xff09;给出算…

安卓第一次搭建C/S架构

1_数据库 2_服务端 服务端简单搭建准入门 使用json&#xff0c;导入jar包复制这段内容后打开百度网盘手机App&#xff0c;操作更方便哦 提取码&#xff1a; 3afj 在项目中建一个文件夹并粘贴进去 json与list的互转&#xff1a; import com.alibaba.fastjson.JSON;import j…

vb.net 中最小化到托盘和锁定窗体大小的问题(notifyIcon的两个重要属性)

最小化到托盘需要用到 NotifyIcon 控件&#xff0c;从工具箱中找到并添加&#xff0c;其余代码如下&#xff1a; 最小化到右下角 & 锁定窗口大小Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ResizeIf Me.WindowState …

面试官不讲武德,竟然问了我18个JVM问题!

前言GC 对于Java 来说重要性不言而喻&#xff0c;不论是平日里对 JVM 的调优还是面试中的无情轰炸。这篇文章我会以一问一答的方式来展开有关 GC 的内容。本文章所说的 GC 实现没有特殊说明的话&#xff0c;默认指的是 HotSpot 的。我先将十八个问题都列出来&#xff0c;大家可…

2月第3周国内域名商TOP10:爱名网排名升至第八

IDC评述网&#xff08;idcps.com&#xff09;02月26日报道&#xff1a;根据WebHosting.info公布的最新数据显示&#xff0c;在2月第3周&#xff0c;国内域名商域名总量十强总体呈下降趋势。其中&#xff0c;降幅最大的是DNSPod&#xff0c;净减16,762个。另外&#xff0c;中国数…

Android JSON数据与实体类之间的相互转化-------GSON的简单用法

Android JSON数据与实体类之间的相互转化-------GSON的用法1_Gson的导入1.1_方法一&#xff1a;直接导入jar包1.2_方法二&#xff1a;引入依赖2_json形式的字符串互转实体对象2.1_json字符串与单个实体对象互转2.2_json与list互转3_遇到的问题3.1_前后端对象成员变量类型不一致…

Java StreamTokenizer quoteChar()方法与示例

StreamTokenizer类quoteChar()方法 (StreamTokenizer Class quoteChar() method) quoteChar() method is available in java.io package. quoteChar()方法在java.io包中可用。 quoteChar() method denotes that matching pairs of this character delimiter, string constants …

decode 实例

以往相关材料&#xff1a; http://blog.csdn.net/arrowzz/article/details/17144651 http://blog.csdn.net/arrowzz/article/details/17144669表id,name,score1,小明,胜2,小明,胜3,小李,负4,小李,负5,小明,负6,小李,胜7,小李,胜效果name,胜,负小明,2,1小李,2,2创建表&#xf…