文件名称:SavingsAccount
介绍说明--下载内容来自于网络,使用问题请自行百度
设计一个类SavingsAccount,定义一个静态数据成员记录存款的年利率(rate),该类的每个成员都包含一个私有的数据成员balance,表示该成员当前的存款数额。提供一个成员函数CalMonthlyInterest(),用以计算月利息(用balance乘以rate再除以12),并将这个月利息加入balance中。提供一个静态成员函数ModifyRate(),用以改变静态数据成员rate的值。定义两个不同的SavingsAccount对象saver1和saver2,当前存款数额balance分别为2000.00和3000.00。首先将rate设置为3 ,计算每个存款人的月息并打印新的结果,然后将rate设置为4 ,再次计算每个存款人的月息并打印新的结果。-(SavingsAccount Class) Create a SavingsAccount class. Use a static data member annual-
InterestRate to store the annual interest rate for each of the savers. Each member of the class contains
a private data member savingsBalance indicating the amount the saver currently has on
deposit. Provide member function calculateMonthlyInterest that calculates the monthly interest
by multiplying the balance by annualInterestRate divided by 12 this interest should be added to
savingsBalance. Provide a static member function modifyInterestRate that sets the static annualInterestRate
to a new value. Write a driver program to test class SavingsAccount. Instantiate
two different objects of class SavingsAccount, saver1 and saver2, with balances of $2000.00 and
$3000.00, respectively. Set the annualInterestRate to 3 percent. Then calculate the monthly interest
and print the new balances for each of the savers. Then set the annualInterestRate to
InterestRate to store the annual interest rate for each of the savers. Each member of the class contains
a private data member savingsBalance indicating the amount the saver currently has on
deposit. Provide member function calculateMonthlyInterest that calculates the monthly interest
by multiplying the balance by annualInterestRate divided by 12 this interest should be added to
savingsBalance. Provide a static member function modifyInterestRate that sets the static annualInterestRate
to a new value. Write a driver program to test class SavingsAccount. Instantiate
two different objects of class SavingsAccount, saver1 and saver2, with balances of $2000.00 and
$3000.00, respectively. Set the annualInterestRate to 3 percent. Then calculate the monthly interest
and print the new balances for each of the savers. Then set the annualInterestRate to
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Q1.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.