473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Some help with this

Some one helped out but completely confused me. this is a senario so i
can take it into the actually program im using(variables a, b, c, d are
generic but i have commented about what they are for)
Im trying to get the compounded interest so that it will work for more
than just annually. I want the user of this program to be able to do
semi annually or monthly even some other defined by the user.

The formula i was given is balance = balance + (balance* (rate/100))
This is my code. Any input is welcome
int main()
{
double a,b,c,d;//a is amount to be invested, b is years
invested
//c is compound time, d is interest rate
char ch;//allows user to enter another investment
do{
system("cls");
cout<<"enter an ammount to invest ";
cin>>a;
cout<<"Enter the years to allow to mature ";
cin>>b;
cout<<"How many times a year will it be compounded? ";
cin>>c;
cout<<"What is the rate ";
cin>>d;
for(int i=0;i<b;i++){
for(int h=0;h<c;i++){
a=a+(a*(d/100));
}
}
cout<<"After "<<b<<" years. You have now "<<e<<"
dollars in the
account\n";
cout<<"Would you like to run another? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
return 0;

}

Dec 14 '06 #1
5 1291

"Drakscon" <dr****@netscape.netwrote in message
news:11**********************@t46g2000cwa.googlegr oups.com...
Some one helped out but completely confused me. this is a senario so i
can take it into the actually program im using(variables a, b, c, d are
generic but i have commented about what they are for)
Im trying to get the compounded interest so that it will work for more
than just annually. I want the user of this program to be able to do
semi annually or monthly even some other defined by the user.

The formula i was given is balance = balance + (balance* (rate/100))
This is my code. Any input is welcome
What help do you need? Do you know the algorithm you need to use? This is
a language newsgroup, not an algorithms newsgroup (and we don't do people's
homework for them). If you need help developing the algorithm for your
problem, you should probably ask your instructor for help, or someone in
your class.

-Howard

Dec 14 '06 #2
"Drakscon" wrote:
Some one helped out but completely confused me. this is a senario so i
can take it into the actually program im using(variables a, b, c, d are
generic but i have commented about what they are for)
Im trying to get the compounded interest so that it will work for more
than just annually. I want the user of this program to be able to do
semi annually or monthly even some other defined by the user.

The formula i was given is balance = balance + (balance* (rate/100))
This is my code. Any input is welcome
int main()
{
double a,b,c,d;//a is amount to be invested, b is years
invested
//c is compound time, d is interest rate
char ch;//allows user to enter another investment
do{
system("cls");
cout<<"enter an ammount to invest ";
cin>>a;
cout<<"Enter the years to allow to mature ";
cin>>b;
cout<<"How many times a year will it be compounded? ";
cin>>c;
cout<<"What is the rate ";
cin>>d;
for(int i=0;i<b;i++){
for(int h=0;h<c;i++){
a=a+(a*(d/100));
}
}
cout<<"After "<<b<<" years. You have now "<<e<<"
dollars in the
account\n";
cout<<"Would you like to run another? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
return 0;

}
I can't tell what it is you are trying to. Learn C++? Produce a practical
program? (You are much too late for this, programs that do this are already
on the Web.) In any event, perhaps this will be helpful. Note that the
usual way of handling this it to do it for $1. Then, at the very end,
multiply by the number of dollars from the query.

http://en.wikipedia.org/wiki/Compoun...imple_Formulas
Dec 14 '06 #3
Drakscon wrote:
Some one helped out but completely confused me. this is a senario so i
can take it into the actually program im using(variables a, b, c, d
are generic but i have commented about what they are for)
Im trying to get the compounded interest so that it will work for more
than just annually. I want the user of this program to be able to do
semi annually or monthly even some other defined by the user.

The formula i was given is balance = balance + (balance* (rate/100))
This is my code. Any input is welcome
What do you need?
int main()
{
double a,b,c,d;//a is amount to be invested, b is years
invested
//c is compound time, d is interest rate
First of all, pick informative variable names. a,b,c,d? completely
meaningless and maintenance nightmare.
char ch;//allows user to enter another investment
do{
system("cls");
cout<<"enter an ammount to invest ";
cin>>a;
cout<<"Enter the years to allow to mature ";
cin>>b;
cout<<"How many times a year will it be compounded? ";
cin>>c;
cout<<"What is the rate ";
cin>>d;
for(int i=0;i<b;i++){
for(int h=0;h<c;i++){
a=a+(a*(d/100));
}
This formula isn't correct. You have divide the rate by the compounding
frequency, otherwise you'll get far more interest than you should.
You'd get the yearly interest rate every compounding period, which is a
swell deal for the investor, but not so much for the bank.

You have the "brute force" algorithm, which is ok. There's a formula
for direct calculation:

A = P * pow(1+r/m, n);

P = Principal
r = Annual interest rate
m = Number of compounding periods per year
n = Total compounding periods (years * periods per year)
A = Amount Earned After n periods

Either will work, and in fact it's useful as a student to do both and
compare.


Brian
--
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.html>
Dec 14 '06 #4
The program has been written and handed in. What i am trying to do is
for my own gain. This is my 3rd time in C++ but the first two years
were in highschool using Borland Turbo C

and on the variables basis those are not the variables i am using. Im
using Amount, Years, Rate, Time

And being lectured isnt very fun. I politly asked for help so thanks
alot

Dec 15 '06 #5
Drakscon wrote:
The program has been written and handed in. What i am trying to do is
for my own gain. This is my 3rd time in C++ but the first two years
were in highschool using Borland Turbo C
Hope you fixed the algorithm.
and on the variables basis those are not the variables i am using. Im
using Amount, Years, Rate, Time
Why didn't you present it that way? You should always show us the real
code. Remember that for the future questions, if there are any.
And being lectured isnt very fun. I politly asked for help so thanks
alot
It's not at all clear who you are addressing, as you rudely failed to
include quotes as is the standard on usenet. However, a learning
situation is exactly when you should expect to be lectured.

Frankly, your attitude towards people who spent quite a bit of time
(for free) trying to help you is pretty disgusting. You should
apologize to the group.


Brian
Dec 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: DJ Craig | last post by:
I use a web hosting service that gives me FTP access to my directory on a Linux server. I use Mac OS X. I write my code in Dreamweaver MX which gives me color-coding, but I get really tired of...
2
by: Joh | last post by:
Hello, (sorry long) i think i have missed something in the code below, i would like to design some kind of detector with python, but i feel totally in a no way now and need some advices to...
0
by: Matthias Blohm | last post by:
Hello, a question about a tool or a possibility how could something work. following situation: we have a database which is full of very sensitive information and needed that db to use our online...
2
by: van | last post by:
Writing classes of some algorithms, some parameters needs to be passed into the classes, the actual algorithms are contained in member functions of classes. What I am thinking is having some...
2
by: sumi | last post by:
I am very new to python , I have small query could some one help me. every time I get a new load i need to do few things like creating some dir, changing some file contents and moving some files ,...
1
by: Billy | last post by:
Hi... I have a problem with a confirm dialog box. I want to execute some code and then prompt the user with a confirm dialog box who's message will depend on the result of the execution from...
5
by: Jeremy | last post by:
This is a variation on the last 2 unresolved questions I've posted. Having removed the "required" attribute from a field that was causing trouble, I'm finding that my dataAdapter update gets...
28
by: Yuri CHUANG | last post by:
"No newline at the end of your output" is really a problem? I've never learned that before. So I desire to know some tips about writting a program perfectly.Can anyone give me some tips which are...
12
by: johannblake | last post by:
First off, I am NOT a beginner. I have lots of experience developing professional web sites and am a professional software developer. Unfortunately I've been out of web site development for the...
46
by: ajba74 | last post by:
Hi fellows, I am reading some books to learn the C programming language, and sometimes I have the feeling that when somebody becomes a C expert, he must learn a more modern and object-oriented...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.