Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Location
    England
    Posts
    12

    Unanswered: Can Someone See What I've Done Wrong

    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.


    I CAN'T GET PAST 1:1, I JUST CAN'T SEE IT PLEASE HELP

  2. #2
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    53

    Re: Can Someone See What I've Done Wrong

    Hi,

    i don't know your compiler, but there seem to be a bunch of syntax errors. i fixed them so far for D6. Also i suggest to use a function for getting the user response:

    Code:
    PROGRAM PRO5(input,output);
    
    // D6 syntax
    // USES crt;
    {$APPTYPE CONSOLE}
    
    
    VAR
    score:real;
    answer:char;
    
    
    function GetKey(validchars:string):char;
    var key:char;
    begin
      repeat
        readln(key);
        key:=upcase(key);
      until pos(key,validchars)>0;
      result:=key;
    end;
    
    
    PROCEDURE Q_1;
    BEGIN
    writeln('What is the abbreviation for "fourth generation language"');
    writeln('A 4GL');
    writeln('B FGL');
    writeln('C 4TH GL');
    
    Answer:=GetKey('ABC');
    
    If (answer = 'B') or (answer='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 (answer='B') OR (answer='C');
    
    If (answer = 'B') or (answer='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 (answer='B') OR (answer='C');
    
    If (answer = 'B') or (answer='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;  ?? not really needed
    answer:=upcase(answer);
    UNTIL answer='N';
    END.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •