Board index » delphi » how do you make multiple read outs?

how do you make multiple read outs?

Hi,
Im very new to programming, just started a course in turbo pascal this year,
and I was wondering if anyone could help me out. I have a program that
computes that interest rates of a savings account, it works fine,  but my
problem is I have to be able give the interest amount and account value for
each year of the period entered. So far I can only work out how to do the
initial year of investment. I can work out the calculations but as the
specific period is an input, how would I go about making a read out for each
year? I hope my question is understandable. Thanks for any advise, i really
appreciate it.

Here is what I have so far:

Program Interest_Rates (input, output);

Var
        deposite, AIR, period, AIA, ACV : real;

Begin
        Writeln('Please enter the annual interest rate for your savings
certificate');
        Readln(AIR);
        Writeln('Enter the investment peiod for your certificate');
        Readln(period);
        Writeln('Enter the amount of your deposite');
        Readln(deposite);

        AIA := AIR / 100 * deposite;
        ACV := AIR + deposite;
        Writeln('Your annual interest amount is ', AIA);
        Writeln('Your annual certificate value is ', ACV);
END.

 

Re:how do you make multiple read outs?


Am Sonntag, 4. Mai 2003 03:00 schrieb odub-:

Quote
> Hi,
> Im very new to programming, just started a course in turbo pascal this
> year, and I was wondering if anyone could help me out. I have a
> program that
> computes that interest rates of a savings account, it works fine,  but
> my problem is I have to be able give the interest amount and account
> value for each year of the period entered. So far I can only work out
> how to do the initial year of investment. I can work out the
> calculations but as the specific period is an input, how would I go
> about making a read out for each year? I hope my question is
> understandable. Thanks for any advise, i really appreciate it.

> Here is what I have so far:

[snipped]

I'm not sure if this does what you want; just try it...

PROGRAM Interest_Rates (input, output);
USES Crt;
VAR     rate, cap_0, cap_end    :REAL;
Var     i, time                 :INTEGER;

BEGIN
        WRITE ('Rate: ');
        READ (rate);
        WRITE ('Time: ');
        READLN (time);
        WRITE ('Amount: ');
        READLN (cap_0);

        cap_end := cap_0;

        FOR i := 1 TO time DO
        BEGIN
                cap_end := cap_end * rate;
        END;

        WRITELN ('You get: ', cap_end:5:2)
END.

Other Threads