Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

error in statement

Posted on 2000-03-23
1
Medium Priority
?
1,623 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Carpathia earned 80 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes Administrators rights are not enough. These cases call for the SYSTEM account. The process in this article outlines the steps required to execute commands using the SYSTEM account.
An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

597 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