merkuries
June 8th, 2008, 01:44 AM
Hi Guys!! Can help me how to create coding for calculating interest rate function? I am stuck... Please help..
Class Account
Hold variables of interest rate and deposit.
Make deposit() Withdrawal() function that checks if money in the account is enough to be withdrawn.
Show output if deposit $5000 for 12 months. 5% interest rate.
Initial deposit $20000.
Write main ()
Codes:
#include <string>
#include <stdio>
#include <stdlib>
#include <conio>
#include <iostream>
class Account
{
private:
int Interest;
double Deposit;
public:
Account()
{
Interest = 0.05;
Deposit = 20000;
}
void makeDeposit();
void withdrawal();
};
void Account::makeDeposit()
{ double amount;
cout << endl << "Deposit Amount : ";
cin >> amount;
Deposit = Deposit + amount;
cout << endl << "Balance : " << Deposit;
}
void Account::withdrawal()
{ double amount;
cout << endl << "Withdrawal Amount : ";
cin >> amount;
if((Deposit>=0)&&(Deposit >= amount))
{Deposit = Deposit - amount;}
cout << endl << "Balance : " << Deposit;
}
void main()
{
Account theAccount;
theAccount.makeDeposit();
theAccount.withdrawal();
}
Class Account
Hold variables of interest rate and deposit.
Make deposit() Withdrawal() function that checks if money in the account is enough to be withdrawn.
Show output if deposit $5000 for 12 months. 5% interest rate.
Initial deposit $20000.
Write main ()
Codes:
#include <string>
#include <stdio>
#include <stdlib>
#include <conio>
#include <iostream>
class Account
{
private:
int Interest;
double Deposit;
public:
Account()
{
Interest = 0.05;
Deposit = 20000;
}
void makeDeposit();
void withdrawal();
};
void Account::makeDeposit()
{ double amount;
cout << endl << "Deposit Amount : ";
cin >> amount;
Deposit = Deposit + amount;
cout << endl << "Balance : " << Deposit;
}
void Account::withdrawal()
{ double amount;
cout << endl << "Withdrawal Amount : ";
cin >> amount;
if((Deposit>=0)&&(Deposit >= amount))
{Deposit = Deposit - amount;}
cout << endl << "Balance : " << Deposit;
}
void main()
{
Account theAccount;
theAccount.makeDeposit();
theAccount.withdrawal();
}