Solved

tried what you said but

Posted on 2000-03-28
1
180 Views
Last Modified: 2010-04-16
I tried putting in that writeln under the uses printer like you said, but it wouldn't let me. What do I do now?  Also, the program needs to output BOTH the number of state capitals gotten in one guess and the number of capitals gotten within one guess (I'd prefer to do this last part separately, but I think I could do it within this one).

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


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;
                         var localcorrect_guess: integer);

   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
         begin
           writeln ('Nice work.  You got it on try ', tries);
           inc(localcorrect_guess)
         end
      else
          begin{until}
           writeln ('You did not get it in 4 tries or less');
           writeln ('The correct answer is ' , capital)
          end;{until}
   end; {GUESS_CAPITAL}

procedure GUESSES (localcorrect_guess: integer);
   begin
     writeln ('You have guessed ' ,localcorrect_guess, ' states in 4 or fewer tries ');
   end;{GUESSES}


begin {main}
     assign (Statefile, 'A:\state2.dat');
     reset (Statefile);
     correct_guess:= 0;
     while not seekeof (Statefile) do
       begin
         GETDATA (Statefile, state, capital);
         GUESS_CAPITAL (tries, guess, correct_guess);
         GUESSES (correct_guess)
       end;
     close (Statefile)
end.
0
Comment
Question by:kazooie21
1 Comment
 
LVL 47

Accepted Solution

by:
dbrunton earned 5 total points
Comment Utility
Something like this

program form;
uses printer;



Rest of code


procedure GUESSES (localcorrect_guess: integer);
begin
  writeln(Lst, 'You have guessed ' ,localcorrect_guess, ' states in 4 or fewer tries ');
end;{GUESSES}


You are using Turbo Pascal aren't you?

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
A procedure for exporting installed hotfix details of remote computers using powershell
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now