home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
REXXCH03.ZIP
/
GAME.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-03-12
|
3KB
|
85 lines
/* This is a scoreboard for a game. Any number of */
/* players can play. The rules for scoring are these: */
/* */
/* Each player has one turn and can score any number of */
/* points; fractions of a point are not allowed. The */
/* scores are entered into the computer and the program */
/* replies with */
/* */
/* the average score (to the nearest hundredth of */
/* a point) */
/* the highest score */
/* the winner (or, in the case of a tie, */
/* the winners) */
/*------------------------------------------------------*/
/* Obtain scores from players */
/*------------------------------------------------------*/
say "Type the score for each player in turn. When all"
say "have been typed, enter a blank line!"
say
n=1
do forever
say "Please type the score for player "n
pull score.n
select
when datatype(score.n,whole) then n=n+1
when score.n="" then leave
otherwise say "The score must be a whole number."
end
end
n = n - 1 /* now n = number of players */
if n = 0 then exit
/*------------------------------------------------------*/
/* compute average score */
/*------------------------------------------------------*/
total = 0
do player = 1 to n
total = total + score.player
end
say "Average score is",
format(total/n,,2,0) /* format "total/n" with */
/* no leading blanks, */
/* round to 2 decimal places */
/* do not use exponential */
/* notation */
/*------------------------------------------------------*/
/* compute highest score */
/*------------------------------------------------------*/
highest = 0
do player = 1 to n
highest = max(highest,score.player)
end
say "Highest score is" highest
/*------------------------------------------------------*/
/* Now compute: */
/* * W, the total number of players that have a score */
/* equal to HIGHEST */
/* * WINNER.1, WINNER.2 ... WINNER.W, the id-numbers */
/* of these players */
/*------------------------------------------------------*/
w = 0 /* number of winners */
do player = 1 to n
if score.player = highest then do
w = w + 1
winner.w = player
end
end
/*------------------------------------------------------*/
/* announce winners */
/*------------------------------------------------------*/
if w = 1
then say "The winner is Player #"winner.1
else do
say "There is a draw for top place. The winners are"
do p = 1 to w
say " Player #",winner.p
end
end
say