I am trying to finish (start) an assignment and I can't get passes what should be a simle parse error. It shows up on the case line of the information function. I have to get rid of it to continue on... and I have tons more to do... Any one able to help? (if you have more suggestions I could sure use them)

Program Calculations (input, output);

VAR
   option:integer;
   loan, monthInterest, years :integer;
   months:integer;
   monthPayment,yearInterest:real;
   factor,saved,information:integer;

   //information:real;
   calculation:integer;
PROCEDURE GetInfo(Var option :integer);

  BEGIN
    writeln;
    writeln ('Please enter one of the following options:');
    writeln (' 1 - Figure out monthly payments for a loan amount');
    writeln (' 2 - Figure out loan amount for a desired monthly payment');
    writeln (' 3 - Figure out how much money can be sved over a number of years');
    writeln (' 4 - Figure out how much needs to be saved to hit a target amount');
    readln  (option);
    END;

 FUNCTION calc (months:real):real ;
  BEGIN
    calc := exp(months* LN(1+monthInterest));
   END;

PROCEDURE GetMoreInfo (loan, monthDeposit, years,NeedSave:integer;
                            monthInterest :real);
  BEGIN
    IF (option = 1) THEN
      Begin
        writeln ('Enter your loan amount, yearly interest and years of loan');
        readln (loan, monthInterest, years);
        months := (years *12);
        END;
    IF (option = 2) THEN
      BEGIN
        write   ('Enter your desired monthly payment, yearly interest');
        writeln ('rate, and the number of years to the loan ');
        readln  ( monthPayment, yearInterest, years);
        monthInterest := (yearInterest /12);
        months := (years *12);
        END;
    IF (option = 3) THEN
      BEGIN
        write   (' Enter the amount you will save, interest rate and ');
        writeln ('number of years');
        readln  (monthDeposit, yearInterest, years);
        monthInterest := (yearInterest /12);
        months := (years *12);
        END;
    IF (option = 4) THEN
      BEGIN
        write   ('Enter the amount you want to save, the yearly  ');
        writeln ('interest and the number of years');
        readln  (NeedSave,monthInterest, years);
        monthInterest := (yearInterest /12);
        months := (years *12);
        END;
      END;



FUNCTION information :real ;
  Case option OF
    1 : information :=factor * monthInterest*loan/(factor-1);
    2 : information := (factor-1)*monthPayment/(factor*monthInterest);
    3 : information := (factor-1)*monthDeposit/monthInterest;
    4 : information := NeedSave *monthInterest/(factor-1);
    END;

  {Case option OF
    1 : MonthPayment :=factor * monthInterest*loan/(factor-1);
    2 : amount := (factor-1)*monthPayment/(factor*monthInterest);
    3 : saved := (factor-1)*monthDeposit/monthInterest;
    4 : monthDeposit := NeedSave *monthInterest/(factor-1);
    END;}

Begin
  GetInfo (option);

  GetMoreInfo (loan, monthDeposit, years,NeedSave, monthInterest);
   factor := calc ;
  calculation := information;
  writeln;
  writeln ('Press <Enter> to end this program');
  readln;
End.

Recommended Answers

All 12 Replies

First of all your function calc's first line


FUNCTION calc (months:real):real ;

should be
FUNCTION calc (months:real);

scratch that i was'nt thinking

Thank you for the reply! I went to one of those online tutors and found the most amazing tutor!!! He was awesome!!! Not only did he help me finish my program but he also taught me everything that I had some how missed! Now I am up to date and ready for this weeks assignment. If anyone wants his name I would be glad to share it!

Hello,

I am glad that you got it working. You might consider posting the solution below, and mention what you had to correct, in order to get the code working.

Glad you are all set,

Christian

The function "Information" must have a Begin/End; block, and so the case statement must be encapsulated with a Begin/End; block.
Just put a Begin/End; block there.

hey can you please let me know how to get intouch with the tutor as i could do with a little help

cheers

hey can you please let me know how to get intouch with the tutor as i could do with a little help

What is it you need to know? I've been doing Pascal / Delphi for 20 years. Maybe I can lend a hand.

I went to Tutor. com and his profile name was Qingfeng J
he was able to explain everything and walk me through what was wrong with my program. Great great tutor!!

But if Daaave is willing to lend his guidance, I am all for trying someone new. I am taking 341 now and Pascal is killing me... I just don't get it.

I've been looking at this code again, and I discovered a problem that hasn't been pointed out, so here I go:

"Information" is declared as a variable of type integer at the top of the program. Further down, "Information" is used as a function name. This will not compile.

Within scope, all program names, constants, variables, types, procedures and functions must have unique names.

Daaave

you seem to know what you are talking about... do you know how to work Delphi... I just got it and am attempting to use it for my current assignment, BUT it has way too many options... i can't figure out how to open the compiler so I can cut and past what I have accomplished using DEv_pascal. Do you kow how to do this?

Yes, I would like the online tutors' information. I am currently taking the first Pascal class (Control Structures) but have to continue with the second class (Data Structures) and sometimes I just get so frustrated trying to figure out just a simple parse error.

Dave, if you are still out there and available to help......I am just having a heck of a time with Begin.End statements mixed in with Repeat, Loop and Procedure calls. I posted my current program at the top of the Forum. Thanks.

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.