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.