comp.lang.ada
 help / color / mirror / Atom feed
From: Andrew <eagletalon@chartermi.net>
Subject: Re: interest computing problem
Date: Wed, 17 Sep 2003 11:05:02 -0500
Date: 2003-09-17T11:05:02-05:00	[thread overview]
Message-ID: <vmh1jlmbuvrb8f@corp.supernews.com> (raw)
In-Reply-To: <vmg4fe84jd79f9@corp.supernews.com>



Andrew wrote:
> 
> 
> tmoran@acm.org wrote:
> 
>>> Your ending balance will be  1.00022E+03
>>
>>
>>   If you use Long_Float instead of Float you will get
>> 1.02014488268319E+03
>> Raising to the 365th, rather than 364th (7*52=364) power gives
>> 1.02020078103290
>> which matches within rounding error what your banker friend says.
> 
> <<<<Snip>>>><<<<Snip>>>>


ok after a few hours of sleep.. I got Long_Float to work(aka the program 
compiled), but the input/output that I got is still

How much money do you have-Please add cents? 1000.00
What is the interest you will receive? .02
How long will it be invested in weeks? 52


Your ending balance will be 1000.20


as you can see it now says that the ending balance is 1000.20 which is 
changed from 1000.22 (and the can probably be attributed to the fact 
that I am using Long_Float instead of Float).  but I am still at the 
problem of the answer should be 1020.20 (or the full answer that he came 
up with 1020.2008).  he did acknowledge the fact that I am really only 
computing for 364 days instead of 365 but none the less, I am loosing 
the equivalent of 20 dollars in the program.  If i was loosing 15 cents 
or some minor amount I would accept that was just because of the loss of 
the day, but 20?  *L* thankfully this isn't a real bank computer program 
or I'd have a lot of pissed off customers.

I think I'm going to ask 2 important question:
based upon the coding which I have pasted at the bottom of the page..
1: is the interest being compounded on a daily basis? (which I believe 
it is and my friend also believes the same.)

2.  is the line of
Balance:=Initialamt * (1.0+DRate)**Days;
really saying.. take the value in DRate and add 1.0 to it and take that 
to the power of the value in Days.
ex:
DRate = 4
Days = 5
Initalamt = 100.00
would really be taken as
100.00 * (1.0 + 4)^5
because if I remember correctly the ** just means 'to the power of'

here is the current coding
======================

with TEXT_IO;
use TEXT_IO;
 

procedure Interest is
    Initialamt : Long_Float;
    Interest : Long_Float;
    TimeNWeeks : Integer;
    DRate : Long_Float;
    Days : Integer;
    Balance : Long_Float;
 

    package NUMBER_IO is new INTEGER_IO(INTEGER);
    use NUMBER_IO;
    package Float1_IO is new Float_IO(Long_FLOAT);
    use Float1_IO;
 

begin
    New_Line;
    Put ("How much money do you have-Please add cents? ");
    Get (Initialamt);

    Put ("What is the interest you will receive? ");
    Get (Interest);
 

    Put ("How long will it be invested in weeks? ");
    Get (TimeNWeeks);
 

    New_Line;
 

    Days:=TimeNWeeks * 7;
    DRate:=(Interest/100.0)/365.0;
    Balance:=Initialamt * (1.0+DRate)**Days;
 

    New_Line;
    Put ("Your ending balance will be ");
    Put (Balance,1,2,0);
 

    New_Line;
end Interest;
=========================================

and here is the bottom line question:
any ideas of where I am loosing the 20 dollars at?
needed answer - current answer = 20
1020.20 - 1000.20 = 20
?

please help
Andrew




  reply	other threads:[~2003-09-17 16:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-16 15:27 interest computing problem Andrew
2003-09-16 15:54 ` Ludovic Brenta
2003-09-16 17:21   ` tmoran
2003-09-17  4:26     ` Andrew
2003-09-16 21:52 ` Robert I. Eachus
2003-09-17  3:48   ` Andrew
2003-09-17  4:28     ` Andrew
2003-09-17  5:18     ` tmoran
2003-09-17  7:47       ` Andrew
2003-09-17 16:05         ` Andrew [this message]
2003-09-17 16:32           ` Martin Dowie
2003-09-17 16:36           ` Stupid! -was- " Andrew
2003-09-17 17:00             ` Stephane Richard
2003-09-17 17:15               ` Andrew
2003-09-19  4:07 ` Leon Winslow
2003-09-21 22:55   ` Andrew
  -- strict thread matches above, loose matches on Subject: below --
2003-09-22  0:44 Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox