program for test scores

An applicant will be given a maximum of five typing tests. He/she will be hired as soon as the scores on two of the tests are over 50. The program should print 'Hire' as soon as the applicant qualifies without asking for further tests. If after five test scores have been entered and the typist still hasn't qualified, the program should print Reject. Here are two sample outputs:

enter score 52
enter score 47
enter score 54
Hire


enter score 41
enter score 48
enter score 52
enter score 49
enter score 48
Reject

Here is my code:
program TypingScore;
var score: integer;
      tries: integer;

begin
      tries := 0;
repeat
      tries := tries + 1;
      write ('Enter score: ');
      readln (score)
until (score > 50) or (tries = 5);
if score > 50 then
    writeln ('Hire;)
else writeln ('Reject');
end.

The program stops when I finally enter a score over 50.
kazooie21Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Alisher_NConnect With a Mentor Commented:
var
  score, good, bad : integer;
begin
  good := 0; bad := 0;
  repeat
     write( 'enter score: ' );
     readln( score );
     if score > 50 then Inc( Good ) else Inc( Bad );
     if Good = 2 then begin writeln( 'hire' ); halt; end;
     if (Good+Bad) = 5 then begin writeln( 'reject'); halt; end;
  until False;
0
 
BatalfCommented:
Or like this :


var
  score, good, bad : integer;
  decision : boolean;
begin
  good := 0; bad := 0;
  decision:=false;
  repeat
     write( 'enter score: ' );
     readln( score );
     if score > 50 then Inc( Good ) else Inc( Bad );
     if Good = 2 then begin
            writeln( 'hire' );
            decision := true;
end;
     if (Good+Bad) = 5 then
        begin
          writeln( 'reject');
          decision:=true;
        end;
  until decision=true;


The program then don't need to halt.
0
 
Alisher_NCommented:
for batalf:

what is the difference ?
'halt' is normal (documented) way to exit from program, actually it does the same thing as 'end.', so I can't see any reason for your version. Moreover, mine was shorter=faster ;-)

0
 
BatalfCommented:
I was just posting an additional comment. All Credit should be given to you :-)
0
 
Alisher_NCommented:
sorry all!
I forgot to put 'end.' in my proposed answer ;-(

0
All Courses

From novice to tech pro — start learning today.