银行存取款案例(c#编程)

银行存取款案例(c#编程)

ID:6611204

大小:30.00 KB

页数:6页

时间:2018-01-20

银行存取款案例(c#编程)_第1页
银行存取款案例(c#编程)_第2页
银行存取款案例(c#编程)_第3页
银行存取款案例(c#编程)_第4页
银行存取款案例(c#编程)_第5页
资源描述:

《银行存取款案例(c#编程)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、银行存取款案例(C#编程)classSavingsAccount{//类字段用于存储帐号、余额和已获利息privateint_accountNumber;privatedouble_balance;privatedouble_interestEarned;//利率是静态的,因为所有帐户获得的利息相同privatestaticdouble_interestRate;//构造函数初始化类成员publicSavingsAccount(intaccountNumber,doublebalance){this._accountNumber=accountNumber

2、;this._balance=balance;}//只读AccountNumber属性publicintAccountNumber{get{return_accountNumber;}}publicdoubleInterestEarned{get{return_interestEarned;}set{//验证数据if(value<0.0){Console.WriteLine("利息不能为负数");return;}_interestEarned=value;}}publicstaticdoubleInterestRate{get{return_interes

3、tRate;}set{//验证数据if(value<0.0){Console.WriteLine("利率不能为负数");return;}else{_interestRate=value/100;}}}publicdoubleBalance{get{if(_balance<0)Console.WriteLine("没有可用余额");return_balance;}set{_balance=value;}}voidputmoney(doublemoney){Console.WriteLine("您原来的存款余额为:{0}",_balance);_balance

4、+=money;Console.WriteLine("您现在的存款余额为:{0}",_balance);}voidgetmoney(doublemoney){Console.WriteLine("您原来的存款余额为:{0}",_balance);_balance-=money;Console.WriteLine("您现在的存款余额为:{0}",_balance);}voidshowbalance(){Console.WriteLine("您现在的存款余额为:{0}",_balance);}staticvoidMain(string[]args){//创建S

5、avingsAccount的对象SavingsAccountobjSavingsAccount=newSavingsAccount(12345,5000);intchoice;do{Console.WriteLine("请选择功能选项:");Console.WriteLine("1、计算利息");Console.WriteLine("2、存钱");Console.WriteLine("3、取钱");Console.WriteLine("4、显示余额");Console.WriteLine("5、退出");choice=Convert.ToInt32(Con

6、sole.ReadLine());switch(choice){case1:{Console.WriteLine("输入到现在为止已获得的利息");objSavingsAccount.InterestEarned=Int64.Parse(Console.ReadLine());Console.WriteLine("输入到现在为止已获得的利率");SavingsAccount.InterestRate=Int64.Parse(Console.ReadLine());objSavingsAccount.InterestEarned+=objSavingsAcc

7、ount.Balance*SavingsAccount.InterestRate;Console.WriteLine("获得的总利息为:{0}",objSavingsAccount.InterestEarned);Console.WriteLine("输入到现在为止已获得的利率");break;}case2:{Console.WriteLine("输入存入的金额");doublemoney=Double.Parse(Console.ReadLine());objSavingsAccount.putmoney(money);break;}case3:{Con

8、sole.WriteLine("输入要取出的金额");double

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。