From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e99ea9c9d228f6b8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-17 09:06:28 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: Andrew Newsgroups: comp.lang.ada Subject: Re: interest computing problem Date: Wed, 17 Sep 2003 11:05:02 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 X-Accept-Language: en-us, en MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:42620 Date: 2003-09-17T11:05:02-05:00 List-Id: 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. > > <<<>>><<<>>> 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