C / C++ Code Portfolio


void applyMonthlyInterest(); // member function to apply one month of interest to savingsBalance static void



Download 112,15 Kb.
bet14/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   ...   10   11   12   13   14   15   16   17   ...   30
Bog'liq
dddd

void applyMonthlyInterest();
// member function to apply one month of interest to savingsBalance
static void setAnnualInterestRate(double newInterestRate);
private:
// member attributes
double savingsBalance;
static double annualInterestRate;
};
}
#endif // !CHRISBERGER_SAVINGSACCOUNT_H

#include "SavingsAccount.h"


#include
using std::cerr;

// initialize static variable annualInterestRate


double ChrisBerger::SavingsAccount::annualInterestRate;

// constructor taking one argument for the initial balance


ChrisBerger::SavingsAccount::SavingsAccount(double initialBalance)
{
// if the initial balance is negative, display an error and set it to 0
if (initialBalance < 0)
{
cerr << "Initial balance must be nonnegative; setting balance to 0\n";
savingsBalance = 0;
}
// otherwise, initialize the balance
else
{
savingsBalance = initialBalance;
}
}

// getter for savingsBalance


double ChrisBerger::SavingsAccount::getSavingsBalance() const
{
return savingsBalance;
}

// setter for annualInterestRate


void ChrisBerger::SavingsAccount::setAnnualInterestRate(double newInterestRate)
{
// if the rate is negative, display an error and set the rate to 0
if (newInterestRate < 0)
{
cerr << "New interest rate must be nonnegative; setting rate to 0\n";
ChrisBerger::SavingsAccount::annualInterestRate = 0;
}
// otherwise, set the rate
else
{
ChrisBerger::SavingsAccount::annualInterestRate = newInterestRate;
}
}

// member function to accure interest on the savingsBalance


void ChrisBerger::SavingsAccount::applyMonthlyInterest()
{
// add one month of interest to the account balance
savingsBalance += savingsBalance *
ChrisBerger::SavingsAccount::annualInterestRate / 12;
}

Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   ...   10   11   12   13   14   15   16   17   ...   30




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish