Hello i'm new to the site so if i'm posting in the wrong area.
i have a programming project for hw that i hae to do. im completely stuck i dont even know where to begin. so if any one can help me i would really appreciate it.
Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the annual interest rate to some initial values (with defaults of zero). The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or a withdrawal (subtract from the balance). Finally, there should be a function that adds interest to the balance at the current interest rate. This function should have a parameter indicating how many years’ worth of interest are to be added (for example, 0.5 years indicates that the account should have six months’ interest added).
Use the class as part of an interactive program that allows the user to determine how long an initial balance will take to grow to a given value. The program should allow the user to specify the initial balance and the interest rate
requirements
The program must run
Implementation of the 8 public member functions (see table below)
The constructor must include default arguments (default value for balance and interest rate).
Public member functions that do not modify the class private variables must be made const.
A function to calculate how long the balance will take to grow to a given value. This function is not part of the account class. It should take two arguments: an object of the account class and a target value. It should return how long should pass until the balance on the account object reaches the target value.
The account object must be a const reference parameter so that inside the function, you call the function to add interest to the balance as many times as needed without actually modifying the object.
The main program should ask the user to specify the initial balance and the interest rate.
The main program should then ask the user to specify a target value.
The main program should print how long the initial balance will take to grow to the target value.
member functions
Constructor
Balance
Annual interest rate
--
Set balance and interest rate to some initial values (with defaults of zero)
Change the current balance
New balance
--
Change the balance to a new value
Change the interest rate
New interest rate
--
Change the interest rate to a new value
Retrieve the current balance
--
Current balance
Return the balance
Retrieve the current interest rate
--
Current interest rate
Return the interest rate
Make a deposit
Deposit amount
--
Add to the balance
Make a withdrawal
Withdrawal amount
--
Subtract from the balance
Add interest to the balance
Years
--
Add interest to the balance at the current interest rate
I would start by building the class. In classes, you have private: stuff, andpublic: stuff. Variables usually go into the private section, and functions go in the public function.
Each variable should have its own "set" and "get" function. The "get" function simply returns the value of the variable. That's it. Just one line of code. The "set" function takes in a value, and sets its variable equal to the new value. Again, just one line of code.
class Puppies{
private:
int lenny;
public:
Puppies();//This is constructor. It sets the starting value. Without it, your variables will have random values to start.
void setLenny(int newlenny);//These are the set and get functions.
int getlenny();
}
// And in Puppies.h.....
void Puppies::Puppies(){
lenny = 5;//So whenever you make a Puppies variable, that variable creates a int lenny = 5;
}
void Puppies::setpuppies(int newlenny){
lenny = newlenny;
}
int Puppies::getpuppies(){
return lenny;
}
It's not an example of your whole assignment, but it's a start.
let me know how it looks. i now need A function to calculate how long the balance will take to grow to a given value. This function is not part of the account class. It should take two arguments: an object of the account class and a target value. It should return how long should pass until the balance on the account object reaches the target value. what does it mean target value? do i have to create an object of the class?
The account object must be a const reference parameter so that inside the function, you call the function to add interest to the balance as many times as needed without actually modifying the object.