why does it not work please help 
Author Message
 why does it not work please help

PROGRAM PRO5(input,output);

USES crt;

VAR
   score:real;
   answer:char;

   PROCEDURE Q_1;
             BEGIN
             repeat
             writeln('What is the abbreviation for "fourth generation
             language"');
             writeln('A 4GL');
             writeln('B FGL');
             writeln('C 4TH GL');
             readln (answer);
                 answer:=upcase(answer);
             until answer:= A OR B OR C;

             If answer = B or C THEN
             writeln('Sorry you are incorrect')
             ELSE
             writeln('You are correct')

             score:= score + 1;

            END;

   PROCEDURE Q_2;
             BEGIN
             repeat
             writeln('What two abbreviations are used for "bits per
             second"');
             writeln('A baud rate + bps');
             writeln('B bps + byte');
             writeln('C bit + baud rate');
             readln (answer);
                 answer:=upcase(answer);
             until answer:= A OR B OR C;

             If answer = B or C THEN
             writeln('Sorry you are incorrect')
             ELSE
             writeln('You are correct')

             score:= score + 1;

            END;

   PROCEDURE Q_3;
             BEGIN
             repeat
             writeln('What abbreviation is used for "computer output on
             microfilm"');
             writeln('A COM');
             writeln('B COOM');
             writeln('C COPOM');
             readln (answer);
                 answer:=upcase(answer);
             until answer:= A OR B OR C;

             If answer = B or C THEN
             writeln('Sorry you are incorrect')
             ELSE
             writeln('You are correct')

             score:= score + 1;

            END;

     BEGIN
          repeat

                clrscr;

                       Q_1;
                       Q_2;
                       Q_3;
                       writeln('score = ' score 'out of 3');
                       readln;
                       score:=0
                       writeln('Do want to play again press Y for yes
                       and N for no');
                       readln(answer);
                       readln;
                       UNTIL answer=<N>;
     END.

it wont even get past 1:1 i can't see why please help

--
live and learn

Posted via http://www.*-*-*.com/



Fri, 18 Nov 2005 21:51:29 GMT  
 why does it not work please help
Quote:

> PROGRAM PRO5(input,output);

> USES crt;

> VAR
>    score:real;
>    answer:char;

>    PROCEDURE Q_1;
>              BEGIN
>              repeat
>              writeln('What is the abbreviation for "fourth generation
>              language"');
>              writeln('A 4GL');
>              writeln('B FGL');
>              writeln('C 4TH GL');
>              readln (answer);
>                  answer:=upcase(answer);
>              until answer:= A OR B OR C;

>              If answer = B or C THEN
>              writeln('Sorry you are incorrect')
>              ELSE
>              writeln('You are correct')

>              score:= score + 1;

>             END;

>    PROCEDURE Q_2;
>              BEGIN
>              repeat
>              writeln('What two abbreviations are used for "bits per
>              second"');
>              writeln('A baud rate + bps');
>              writeln('B bps + byte');
>              writeln('C bit + baud rate');
>              readln (answer);
>                  answer:=upcase(answer);
>              until answer:= A OR B OR C;

>              If answer = B or C THEN
>              writeln('Sorry you are incorrect')
>              ELSE
>              writeln('You are correct')

>              score:= score + 1;

The above increases the score whether the answer is right of wrong,
you probably wanted to do this:
              ELSE BEGIN
                   writeln('You are correct')
                   score:= score + 1;
                   END;  

- Show quoted text -

Quote:

>             END;

>    PROCEDURE Q_3;
>              BEGIN
>              repeat
>              writeln('What abbreviation is used for "computer output on
>              microfilm"');
>              writeln('A COM');
>              writeln('B COOM');
>              writeln('C COPOM');
>              readln (answer);
>                  answer:=upcase(answer);
>              until answer:= A OR B OR C;

>              If answer = B or C THEN
>              writeln('Sorry you are incorrect')
>              ELSE
>              writeln('You are correct')

>              score:= score + 1;

>             END;

>      BEGIN
>           repeat

>                 clrscr;

>                        Q_1;
>                        Q_2;
>                        Q_3;
>                        writeln('score = ' score 'out of 3');
>                        readln;
>                        score:=0
>                        writeln('Do want to play again press Y for yes
>                        and N for no');
>                        readln(answer);
>                        readln;
>                        UNTIL answer=<N>;
>      END.

> it wont even get past 1:1 i can't see why please help

> --
> live and learn

> Posted via http://dbforums.com

What do you mean you can't get past 1:1?
Score should be initialized before Q_1 is called.

Cheers Hanford



Sat, 19 Nov 2005 00:25:15 GMT  
 why does it not work please help

Working from memory (compiler unavailable at the moment)...

Quote:
>              until answer:= A OR B OR C;

Until answer in ['A', 'B', 'C']

Quote:
>              If answer = B or C THEN

If answer in ['B', 'C']

and so on for other cases.

Quote:
>         repeat

>               clrscr;

score := 0;

Note that this is a personal preference.  I rarely assume the language or
system pre-zeros things for me.  In this case, since you have to zero it for
each loop anyway, it just makes sense to do it before it's used.

Quote:
>                        writeln('score = ' score 'out of 3');

Writeln ('score = ', score, 'out of 3');

Quote:
>                        score:=0

You can get rid of this one.

Quote:
>                        writeln('Do want to play again press Y for yes
>                        and N for no');

Can you actually split a string constant across lines like this?

Quote:
>                        readln(answer);
>                        readln;
>                        UNTIL answer=<N>;

Until UpCase(answer) = 'N';

Quote:
> it wont even get past 1:1 i can't see why please help

What's "1:1" ?

    - Bill



Sat, 19 Nov 2005 07:42:37 GMT  
 why does it not work please help

the error list it stops at xy 1:1 saying fatal something error begin
expected but [ found, but 1:1 is the start of "program5
(input,output);" ??
i dont think i have a mind for programming, but i'm hoping practise will
make perfect ;)

--
live and learn

Posted via http://dbforums.com



Sat, 19 Nov 2005 16:39:34 GMT  
 why does it not work please help

i've made all the changes suggested but it still won't work it has these
error messages

Quote:
>20 / 17 program5.pas

 Error: Incompatible types: got "CHAR" expected "LONGINT"
Quote:
>20 / 41 program5.pas

 Error: Incompatible types: got "BOOLEAN" expected "LONGINT"
Quote:
>41 / 38 program5.pas

 Fatal: Syntax error, THEN expected but ) found

i don't know how it got boolean

--
live and learn

Posted via http://dbforums.com



Sat, 19 Nov 2005 17:10:45 GMT  
 why does it not work please help


Quote:

>PROGRAM PRO5(input,output);

>USES crt;

>VAR
>   score:real;
>   answer:char;

>   PROCEDURE Q_1;
>             BEGIN
>             repeat
>             writeln('What is the abbreviation for "fourth generation
>             language"');
>             writeln('A 4GL');
>             writeln('B FGL');
>             writeln('C 4TH GL');
>             readln (answer);
>                 answer:=upcase(answer);
>             until answer:= A OR B OR C;

>             If answer = B or C THEN
>             writeln('Sorry you are incorrect')
>             ELSE
>             writeln('You are correct')

>             score:= score + 1;

>            END;

>   PROCEDURE Q_2;
>             BEGIN
>             repeat
>             writeln('What two abbreviations are used for "bits per
>             second"');
>             writeln('A baud rate + bps');
>             writeln('B bps + byte');
>             writeln('C bit + baud rate');
>             readln (answer);
>                 answer:=upcase(answer);
>             until answer:= A OR B OR C;

>             If answer = B or C THEN
>             writeln('Sorry you are incorrect')
>             ELSE
>             writeln('You are correct')

>             score:= score + 1;

>            END;

>   PROCEDURE Q_3;
>             BEGIN
>             repeat
>             writeln('What abbreviation is used for "computer output on
>             microfilm"');
>             writeln('A COM');
>             writeln('B COOM');
>             writeln('C COPOM');
>             readln (answer);
>                 answer:=upcase(answer);
>             until answer:= A OR B OR C;

>             If answer = B or C THEN
>             writeln('Sorry you are incorrect')
>             ELSE
>             writeln('You are correct')

>             score:= score + 1;

>            END;

>     BEGIN
>          repeat

>                clrscr;

>                       Q_1;
>                       Q_2;
>                       Q_3;
>                       writeln('score = ' score 'out of 3');
>                       readln;
>                       score:=0
>                       writeln('Do want to play again press Y for yes
>                       and N for no');
>                       readln(answer);
>                       readln;
>                       UNTIL answer=<N>;
>     END.

>it wont even get past 1:1 i can't see why please help

{Keeping as much of your work as I could, (although only one procedure
is shown). Following your version is modified version, if you are
interested.}

PROGRAM PRO5(input,output);

USES crt; {CAN BE TROUBLE WITHOUT MODIFICATION FOR HIGH SPEED PC}

VAR
   {score:real;} score:integer;
   answer:char;

   PROCEDURE Q_1;
             BEGIN
             repeat
   writeln('What is the abbreviation for "fourth generation
language"');
             writeln('A 4GL');
             writeln('B FGL');
             writeln('C 4TH GL');
             readln (answer);
                 answer:=upcase(answer);
  {----->}   until (answer = 'A') OR (answer = 'B') OR (answer = 'C');

             If (answer = 'B') or (answer = 'C') THEN
             writeln('Sorry you are incorrect')
             ELSE
             begin {<----}
             writeln('You are correct');   {<--- semicolon}

             score:= score + 1;
             end;
            END;
(* All the following procedures can be modified as above *)

     BEGIN
          repeat

                clrscr;
                score := 0;  {<----}
                       Q_1;
                     (*  Q_2;
                       Q_3; *)
       {commas--->}  writeln('score = ', score, ' out of 3');
                       (* readln;  score:=0 *)
      writeln('Do want to play again press Y for yes and N for no');
                       readln(answer);
                       (* readln; *)
                       UNTIL (* answer=<N> *)   UpCase(answer) = 'N';
     END.

{There are many different ways to do multiple choice tests.
The correct answers should not all be the same char. One
way is to let the computer do most of the work by putting all
the questions and answers in a text file in a fixed format with
some way of identifying the correct answer. Now you can use a
single procedure to display questions and answers for any exam
you want to make with different numbers of choices.}

Program Pro5;     { The correct answere are not all 'A'! }
VAR
   ct, score:integer;
   response:Char;

Procedure Grade(ans, correct:Char; VAR scor:Integer);
Begin
   If ans <> correct THEN  writeln('Sorry you are incorrect')
   ELSE
   begin
        writeln('You are correct');
        Inc(scor);
   end;
End;

PROCEDURE Q_1(correct:char; VAR scor:Integer);
VAR answer:Char;
BEGIN
repeat
 writeln('What is the abbreviation for "fourth generation language"');
   writeln('A 4GL');
   writeln('B FGL');
   writeln('C 4TH GL');
   readln (answer);
   answer:=upcase(answer);
until (answer >= 'A') and (answer <= 'C');
   Grade(answer, correct, scor);
END;

PROCEDURE Q_2(correct:char; VAR scor:Integer);
VAR answer:Char;
BEGIN
repeat
   writeln('What two abbreviations are used for "bits per second"');
   writeln('A bps + byte');
   writeln('B baud rate + bps');
   writeln('C bit + baud rate');
   readln (answer);
   answer:=upcase(answer);
until (answer >= 'A') and (answer <= 'C');
   Grade(answer, correct, scor);
END;

PROCEDURE Q_3(correct:char; VAR scor:Integer);
VAR answer:Char;
BEGIN
repeat
   write('What abbreviation is used for "computer ');
   writeln('output on microfilm"');
   writeln('A COPOM');
   writeln('B COM');
   writeln('C COOM');
   readln (answer);
   answer:=upcase(answer);
until (answer >= 'A') and (answer <= 'C');
   Grade(answer, correct, scor);
END;

BEGIN  {main}
repeat
     score := 0;
     For ct := 1 to 3 do
     Begin
          writeln; writeln; writeln;
          Case ct of
               1: Q_1('A', score);
               2: Q_2('B', score);
               3: Q_3('C', score);
          end;
     End;
     writeln('score = ', score, ' out of 3');
     write('Do want to play again (Y/N)? ');
     readln(response);
UNTIL  UpCase(response) = 'N';
END.



Sun, 20 Nov 2005 04:44:55 GMT  
 why does it not work please help

Quote:
> 1.  None of us speak that 20/17 business; we like to see actual
> program lines in front of us.

Ah, thanks.  The light just went on for me, with a big "duh.".  Line 20,
column 17.

I never look at that myself, since I compile in the IDE and the cursor leaps
to the error for me, and I never think about it.

    - Bill



Sun, 20 Nov 2005 11:26:40 GMT  
 why does it not work please help

Thanks for your responces, they have been a great help and I was chuffed
when my program worked. I relised alot of my errors and corrected them.
I'm afraid i'm one of those people that make aload of daft errors then
can't see them for looking. Hopefully with more practise i will be able
to do this myself, but until then i'm afraid that i will have to keep
mithering good people like yourselves. Thankyou again for all your help
and talk to again on my next failed attempt which i feel is coming quite
soon, i have not finnished trying it out yet by myself.  ;)

--
live and learn

Posted via http://dbforums.com



Mon, 21 Nov 2005 00:21:46 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. why not all the Virtual Key codes work ?

2. Why does this not work?

3. Bookmarks - why do they *not* work??

4. CusorPosChanged is not working, why

5. Debug functions in BP not working - why?

6. Query under 2.0 not working, why?

7. Why the cancel does not work?

8. HELP : "Invalid Paramater", when doing Tquery.Open, seems to not release resources

9. Capability Not supported.....why not?

10. Need Help: Why BDE Error [Not initialized for....]

11. programming help **please help me** its not hard

12. Help : Setfocus does not work

 

 
Powered by phpBB® Forum Software