Just trying to make my program user friendly...but I get the response 'Wrong' when I enter in a number or abcd when really I want my error message displayed when the user enters input like that and ONLY a Correct or Wrong response when the user enters 'A' 'B' 'C' or 'D', any ideas?
Program Quiz;
uses crt;
Var
Quizfile : Text;
Line : String;
answer : Char;
I, Money, Score : Integer;
Begin
clrscr;
Money :=0;
Score :=0;
Assign(Quizfile, 'E:\test.dat');
Reset (Quizfile);
While not EOF (Quizfile) DO
Begin
FOR I:= 1 TO 5 DO
Begin
Readln(Quizfile, line);
Writeln(line);
End;
Readln(Quizfile, line);
Repeat
Writeln('Please enter the letter you think is correct');
Readln(answer);
IF UPCASE(answer) = line THEN
Begin
Writeln('Correct');
Money := Money +5;
Score := Score +1;
End
ELSE IF (UPCASE(answer) <=UPCASE('a'))
OR (UPCASE(answer) <=UPCASE('b'))
OR (UPCASE(answer) <=UPCASE('c'))
OR(UPCASE(answer) <=UPCASE('d')) THEN
Begin
Writeln('Wrong');
Money := Money-5;
Score := 0+Score;
End
ELSE
Begin
Writeln('Only A,B,C or D are options!!!!');
End;
Until (UPCASE(answer) <=UPCASE('a'))
OR (UPCASE(answer) <=UPCASE('b'))
OR (UPCASE(answer) <=UPCASE('c'))
OR(UPCASE(answer) <=UPCASE('d'));
Writeln('Money Won is £', money);
Writeln('Score out of 12 questions is ', score);
Writeln('Please press Return');
Readln;
clrscr;
End;
Close (Quizfile);
End.