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-19 22:49:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!newsfeed.stueberl.de!proxad.net!isdnet!212.156.2.61.MISMATCH!news.ttnet.net.tr!not-for-mail From: Leon Winslow Newsgroups: comp.lang.ada Subject: Re: interest computing problem Date: Fri, 19 Sep 2003 00:07:22 -0400 Organization: Another Netscape Collabra Server User Message-ID: <3F6A80FA.3ECF8B55@notes.udayton.edu> References: NNTP-Posting-Host: 131.238.72.220 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en To: Andrew Xref: archiver1.google.com comp.lang.ada:42712 Date: 2003-09-19T00:07:22-04:00 List-Id: Andrew Your program is a good example of a student homework program. It works, as long as you remember all of the assumptions you made in writing it. This is about as much as most instructors expect of their students and I'm sure you got a good grade on it. It might be instructive, however, to rewrite it in a more robust version. For example, define some data types and check the input for valid values. Thus, real money is always integers (minimum value is one cent, not .00001 or some such) and interest is either an integer type 3% or a float type .12% depending on what you want. Note this will require you to define exactly how one computes interest times dollars. All of these details are one reason real programs tend to look long and complicated to outsiders. If you can do a robust version of this problem, you will have accomplished something past what your instructor expected. Its always good to see another new Ada programmer. Good luck in your endeavors. Lee Winslow Andrew wrote: > ok I've run into a snag .. and i'm hoping that a programmer can help me > out. > > here is a copy of my program (written in Ada) > > ==== > -- computes Interest on money invested > > with TEXT_IO; > use TEXT_IO; > > procedure Interest is > Initialamt : Float; > Interest : Float; > TimeNWeeks : Integer; > DRate : Float; > Days : Integer; > Balance : Float; > > package NUMBER_IO is new INTEGER_IO(INTEGER); > use NUMBER_IO; > package Float1_IO is new Float_IO(FLOAT); > use Float1_IO; > > begin > New_Line; > Put ("How much money do you have-Please add cents? example 365.22 "); > 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); > > > New_Line; > end Interest; > > ======================================== > > now here is the output from when I try to run the program > ================== > How much money do you have-Please add cents? .02 > What is the interest you will receive? 25 > How long will it be invested in weeks? 4 > > Your ending balance will be 2.03872E-02 > [andrew@stc program]$ ./interest > > How much money do you have-Please add cents? .02 > What is the interest you will receive? .25 > How long will it be invested in weeks? 4 > > Your ending balance will be 2.00038E-02 > > ============ > > but I'm hoping that this is just a simple case of I .. well *L* I'm > hoping this is a simple error that I'm overlooking.. > > sub-note : this program is directly copied from a printout of a program > that I wrote in college (and it worked on the colleges computers). > > By the way I'm writing this on a Red Hat Linux 9.0 computer (I don't > think that would matter but ..)