Solved

error in statement

Posted on 2000-03-23
1
1,615 Views
Last Modified: 2006-11-17
I have created a text file with 10 states and their capitals. I need an interactive program that will produce as its final output the number of states for which the user was able to guess the capital in four or less tries.



Here's what I got:

var state: string;
    capital : string;
    Statefile: text;
    tries: integer;
    guess: string;

procedure GETDATA (var localStatefile: text;
                   var localstate: string;
                   var localcapital: string);

   begin
      readln (localStatefile, localstate);
      readln (localStatefile, localcapital);
   end; {GETDATA}

procedure GUESS_CAPITAL (var tries: integer;
                         guess: string);

   begin{GUESS_CAPITAL}
     tries := 0;
     repeat
       tries := tries + 1;
       write ('Give capital of ', state, ' ' );
       readln (guess)
     until (guess = capital) or (tries <= 4);
      if guess = capital then
         writeln ('Nice work.  You got it on try ', tries);
      else
        begin{until}
           writeln ('You did not get it in 4 tries or less');
           writeln ('The correct answer is ' , capital)
        end;
      if tries <= 4 then
        writeln ('You got these states in 4 tries or less: ' , state);
      else
        begin
           writeln ('You didn't get these states: ' , state);
        end;{until}
   end;{GUESS_CAPITAL}


begin {main}
     assign (Statefile, 'A:\state2.dat');
     reset (Statefile);
     while not seekeof (Statefile) do
       begin
         GETDATA (Statefile, state, capital);
         GUESS_CAPITAL (tries, guess);
       end;
     close (Statefile)
end.

Everytime I compile this I get "Error in statment" on one of the else in the GUESS_CAPITAL procedure.
0
Comment
Question by:kazooie21
1 Comment
 

Accepted Solution

by:
Carpathia earned 20 total points
ID: 2651480
When you do an IF.. THEN.. ELSE
you shouldnt terminate the IF with a semicolon.

So it should be

if guess = capital then
         writeln ('Nice work.  You got it on try ', tries)
      else
        begin{until}
           writeln ('You did not get it in 4 tries or less');
           writeln ('The correct answer is ' , capital)
        end;
     

Hope this helps.

0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question