473,471 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Investment program C++ interest rate declines

3 New Member
I just can't get the gradually declines part.
Oct 4 '14 #1
7 2673
Rabbit
12,516 Recognized Expert Moderator MVP
Instead of using the formula to calculate all 10 years at once, use it to calculate 1 year at a time in a loop. Adjusting the interest within the loop.
Oct 4 '14 #2
jwilley
3 New Member
I'm a very beginner. Would it be possible to do an example for please?
i appreciate it.
Oct 4 '14 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Please post the code that you currently have, we can then tell you what you need to change.

But basically, in pseudocode, you would want to do something like this.
Expand|Select|Wrap|Line Numbers
  1. loop from 1 to 10
  2.    runningTotal = growthFormula(1 year, interest rate, runningTotal)
  3.    interest rate = interest rate - decrement
  4. end loop
Oct 4 '14 #4
jwilley
3 New Member
Below is my program, but I'm probably not doing anything right here. I need a program that calculates the final value of a ten year, $20,000 investment whose annual return gradually declines from 5% to 2% over that term.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     float balance      = 10000;     // account balance
  8.     float interest     = .02;       // interest rate
  9.     float rateOfChange = .001;          // interest rate of change
  10.  
  11.     for(int i = 0;i < 10; i++)
  12.     {
  13.         balance += balance * interest;
  14.         interest -= rateOfChange;
  15.     }
  16.  
  17.     cout << "The value after ten years is: $" << balance << endl;
  18.  
  19.     return 0;
  20. }
  21.  
Oct 5 '14 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
"gradually declines" is very vague. How about "declines from 5% to 2% in annual 1/4 % decrements?

That way you could reduce the rate of return by a known amount over a defined period.
Oct 5 '14 #6
Rabbit
12,516 Recognized Expert Moderator MVP
You said you wanted the interest to start at 5% but you have it starting at 2. And you said you want it to drop 3% over the 10 years but you only have it dropping a tenth of a percent each year. If you want it to drop 3 percent, it needs to drop three tenths each year.
Oct 5 '14 #7
donbock
2,426 Recognized Expert Top Contributor
"gradually declines" is very vague. You may need to seek clarification from the instructor. I can think of three ways to interpret this (listed below in order from easy to hard):
  1. The interest rate declines like a staircase: it stays constant until it abruptly decreases; the changes occur once each year on the anniversary of the investment and each step is the same size each time. (This is what weaknessforcats proposed above.)
  2. Same as above except the changes occur each day (or each minute or each second).
  3. No staircase: linear decline (interest is never constant, it changes from moment to moment).
The difficulties with declines #2 and #3 are primarily in determining the right mathematical formula to use ... not so much with implementing the formula on the computer.
Oct 6 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jason | last post by:
I need help designing a query (or two) in MS Access that will calculate a compounded rate of interest. This would be no problem using a simple FV function if the Interest Rate were constant....
1
by: c_beginner | last post by:
yes, this is my how work question. Since I am lack in getting an assistance with my lab work I put this in this advance group. Sorry for the trouble I am making. Write a program to calculate the...
1
by: Drakscon | last post by:
Im trying to get the compounded interest to go back only being compounded annually. I want the user of this program to be able to do semi annually of monthly or some other. This is my code. Any...
2
by: fatimahtaher | last post by:
Hi, I am new to C# programming and my first assignment requires me to calculate total interest paid on a loan. The user will input the loan, the interest rate per month, and the monthly payment....
1
by: Bl00dFox | last post by:
Hi I am making a simple program to calculate interest. At the beginning when the user has to pick 1 or 2 (to select simple or compound interest respectively), if the user enters a letter (eg, a)...
1
by: lenin42001 | last post by:
Please can you help Have tried various means but cannot get this to work. The saver is prompted for the amount they wish to invest & a time period(in years) If initial investment is over £1000 & if...
4
by: bc070200263 | last post by:
This is an Islamic law that Muslims should pay their Zakat with the rate of 2.5%, means in Rs 100 they should pay Rs 2.5 as Zakat amount. Write a simple program which asks from the user The total...
4
by: rhivka | last post by:
I'm going to try to keep this question within the student posting guidelines. I've been working on a class file, and I'm not sure I've constructed it correctly. I'm getting several errors concerning...
14
Dököll
by: Dököll | last post by:
Greetings and salutations! Hope it's a good week thus far... Got myself thinking and wanted to see what can be achieved with a certain bit of code: public double getPayment( ) { ...
2
by: fury30 | last post by:
this is the program as below and now what i need to do is add the following to it but i am not able to get how to do it # futval.py # A program to compute the value of an investment # ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.