comp.lang.ada
 help / color / mirror / Atom feed
* interest computing problem
@ 2003-09-16 15:27 Andrew
  2003-09-16 15:54 ` Ludovic Brenta
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Andrew @ 2003-09-16 15:27 UTC (permalink / raw)



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 ..)




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2003-09-21 22:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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