Hi I have Turbo pascal and my teacher told us to find how much a guy will earn if he puts in a hundread dollars a month till he's sixty at 5 percent interest. (compound interest that is)
Help me please, Here's the code:=

Program retirement_fund (input,output);
USES winCRT;
VAR
interest:real;
fname,lname,sex:string;
age,counter,rage,rage2:integer;
Procedure cal (Var counter,rage2,rage:integer);
Begin
rage2:=60-age;
rage:=rage2*12*100;
interest:=(5/100*rage)+rage;
writeln (fname,' ',lname,' ',age,' years old ', 'will recieve a payment of ',interest:0:2,' when age 60 ');
End;

Begin
writeln ('Enter first name: ');
readln (fname);
clrscr;
writeln ('Enter second name ');
readln (lname);
clrscr;
writeln ('Enter sex ');
readln (sex);
clrscr;
writeln ('Enter age ');
readln (age);
cal (counter,rage2,rage);
cal2 (interest);
End.

Recommended Answers

All 4 Replies

Your program has errors - nor will it calculate compound interest. Give variables clear descriptive names. That will help you keep track when programming. Always put comments within the program. When you come to update your program, particularly if it is a big one, or simply try to recall what it is all about, you will appreciate having attended to these details.

I have rehashed your program (but not saying mine is perfect) but you'll get the idea.

program retirement_fund (input,output);
uses WinCrt;
var
  FirstName, LastName :string;
  PresentAge, RetirementAge, TermOfMonths, Month :integer;
  BankBalance, Deposit, InterestRate :real;

procedure PersonalInfo;
begin
  writeln('Enter first name');
  readln(FirstName);
  writeln('Enter second name');
  readln(LastName);
  writeln('Enter present age');
  readln(PresentAge);
end;                          {ends PersonalInfo}

procedure InterestRateCalcs;
begin
  RetirementAge := 60;
  TermOfMonths := (RetirementAge-PresentAge)*12;
  InterestRate := 5;
  InterestRate := InterestRate/100/12;    {for monthly calc}
  BankBalance := 0;                       
  Deposit := 100;                         {monthly deposit}
  {each month interest is added to the current bank balance}
  for Month := 1 to TermOfMonths do
    BankBalance := (BankBalance+Deposit)*(1+InterestRate);
  writeln;
  writeln('Bank balance at retirement is $',BankBalance:8:2);
end;                          {ends InterestRateCalcs}

begin                         {begins main program}
  ClrScr;
  PersonalInfo;
  InterestRateCalcs;
end.                          {ends main program}

please,can you send me pascal code on how to calculate compound interest
Thank you

Ha! Ha! Do I detect a tease here?

This thread, despite its originator naming it as simple interest, is, in fact, about compound interest, which the originator actually states in line three of his query.

My interest (neither simple, nor compound, but programming) was about code rather than semantics, so I was untroubled by the thread's imprecise title.

*Python unlike PHP and Ruby, is a general purpose language not specifically geared just on web development but more for faster prototyping, for example for whatever project in C/C++, you could do with Python a lot faster, plus the fact that its a lot less error prone than C/C++, especially as your program gets bigger, so less time DEBUGGING!(thats a lot of time saved, believe me), and you can try pieces of your code in the interactive shell, give Python a shot so you see what I mean.
===================

SEO services | PSD to HTML

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.