资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
class SavingsAccount / private int _accountNumber;private double _balance;private double _interestEarned;/ private static double _interestRate;/ public SavingsAccount(int accountNumber, double balance) this._accountNumber = accountNumber;this._balance = balance; / AccountNumber public int AccountNumber get return _accountNumber; public double InterestEarned get return _interestEarned; set / if (value 0.0) Console.WriteLine(); return; _interestEarned = value; public static double InterestRate get return _interestRate; set / if (value 0.0) Console.WriteLine();return; else _interestRate = value / 100; public double Balance get if (_balance 0) Console.WriteLine(); return _balance; set _balance = value; void putmoney(double money) Console.WriteLine(0, _balance); _balance += money; Console.WriteLine(0, _balance); void getmoney(double money) Console.WriteLine(0, _balance); _balance -= money; Console.WriteLine(0, _balance); void showbalance() Console.WriteLine(0, _balance); static void Main(string args) / SavingsAccount SavingsAccount objSavingsAccount = new SavingsAccount(12345, 5000); int choice; do Console.WriteLine(); Console.WriteLine(1); Console.WriteLine(2); Console.WriteLine(3); Console.WriteLine(4); Console.WriteLine(5); choice= Convert.ToInt32( Console.ReadLine(); switch (choice) case 1: Console.WriteLine(); objSavingsAccount.InterestEarned = Int64.Parse(Console.ReadLine(); Console.WriteLine(); SavingsAccount.InterestRate = Int64.Parse(Console.ReadLine(); objSavingsAccount.InterestEarned += objSavingsAccount.Balance * SavingsAccount.InterestRate; Console.WriteLine( 0, objSavingsAccount.InterestEarned); Console.WriteLine(); break; case 2: Console.WriteLine(); double money = Double.Parse(Console.ReadLine(); objSavingsAccount.putmoney(money); break; case 3: Console.WriteLine(); double money = Double.Parse(Console.ReadLine(); objSavingsAccount.getmoney(money); break; case 4: objSavingsAccount.showbalance(); break; case 5: break; while (choice != 5);
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号