|
-
June 8th, 2008, 01:44 AM
#1
Coding for Interest rate
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:
Code:
#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();
}
Last edited by ovidiucucu; June 8th, 2008 at 04:43 AM.
Reason: [CODE] tags added
-
June 8th, 2008, 03:54 AM
#2
Re: Coding for Interest rate
-
June 8th, 2008, 04:06 AM
#3
Re: Coding for Interest rate
Code tags...
int main not void main...
Use the constructor's initialiser list
Specify the actual problem...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|