ELEMENTARY STATISTICS


Could you draw a bar chart (histogram) of a given set of numbers?

Could you understand a bar chart which someone else had written? Here you can test your knowledge on bar charts and means by answering as many questions on these subjects as possible, in five minutes.

This program has an added feature which is that the bar chart will be drawn, by the computer, at the end of the problem. In addition an explanation will be provided.


How to play

You will be given five minutes to answer as many questions as possible, and you may press P and RETURN for pass if you cannot work out an answer.

You will not be penalised for 'passes'.

At the end of five minutes, or sooner, if you enter N for NO in answer to the question "do you want any more", your score sheet showing tries, correct answers and average time per answer will appear. If you wish to proceed then press Y and RETURN and the program will continue to ask you questions.

You can have two tries at each question if you wish. After the first attempt you will be given a hint as to the correct answer. If your second answer is wrong you will be told the solution and how it was obtained.

If you cannot work out an answer then press ? and RETURN and your computer will turn into a calculator and you can then use the normal mathematical symbols on the keyboard. To clear the calculator from the screen press AC and RETURN. For the calculator's answer press = and RETURN. To return to the main game press ? and RETURN. Always remember to press RETURN after each required response.

Programming hints

The box chart is drawn using solid squares. These are user defined characters with all pixels filled in and are created at the beginning of the program using VDU 23. The bar chart is held in N(0) and N(1). The number of each of the marks are held in the array F and the bar chart is drawn from this.

You could increase the number of scores. To do this you must increase the maximum value of J in line 310. The array D would have to be reDIMensioned in line 30. Remember also, if more scores are used then the sum or the marks must divide by a number larger than 9 in line 430 to get the correct mean value.

The maximum number of any particular mark would also be greater than 9 so the maximum value of I in line 510 would have to be increased.


   10 REM QUIZ          - ELEMENTARY STA
TISTICS
   20 REM Copyright (C) G.Ludinski 1983
   30 DIM F(4),D(9),N$(1),IP$(255)
   40 MODE 4
   42 VDU 23,224,255,255,255,255,255,255
,255,255
   50 S$="                              
          "
   52 HC$=" Highest score ":HK$="     Sc
ore "
   60 COLOUR1:COLOUR128:PRINT''''"  Quiz
 game 4 - Elementary Statistics"
   70 PRINT''
   80 INPUT"Hello, what's your name",NAM
$:PRINT'"Here are some problems ";:IF NA
M$ <> "NO SOUND" THEN PRINTNAM$ELSEPRINT
   90 W=1:C=0:T=1:I$="":TIME=0:P=0:MAX=0
  100 P=P+1
  110 PROC_QUESTION
  120 PRINT:PRINT
  130 PRINT:PRINT" = ";:PROC_KEYIN:PRINT
  140 IFI$="?" THEN PROC_CALC
  142 IF A=0 AND I$<>"0" THEN GOTO 190
  150 IF ABS(VAL(I$)-A)<= X AND I$<>"" T
HEN 170
  160 GOTO190
  170 PRINT'"Yes, congratulations":C=C+1
:PRINT:IFNAM$="NO SOUND"THEN220
  180 SOUND1,-10,12,10:SOUND1,-10,20,10:
SOUND1,-10,28,10:SOUND1,-10,32,20:SOUND1
,-10,14,20:GOTO220
  190 IF T=1 THEN PRINT'"No, "H$", try a
gain":T=2:GOTO130
  200 PRINT'"Sorry, the answer is = "'' 
L$''M$
  210 PRINT:PRINTN$(1),N$(0)
  220 IF TIME >=30000 THEN PROC_SCORE
  230 PRINT'"More (Y/N)";:PROC_KEYIN:PRI
NT
  240 IF I$<>"Y" AND I$<>"N" AND I$<>"" 
AND I$<>"YES" AND I$<>"NO" THEN 230
  250 IF I$="Y" OR I$="YES" OR I$="" THE
N T=1:CLS:GOTO100
  251 PROC_SCORE:GOTO 9999
  252 DEFPROC_QUESTION
  260 L$="":M$="":N$(0)="":N$(1)="":S=0:
F(1)=0:F(2)=0:F(3)=0:F(4)=0:G$="":FOR J=
1 TO 9
  270   D(J)=RND(4):G$=G$+STR$(D(J))+","
:S=S+D(J)
  280   FOR K=1 TO 4:IF D(J)=K THEN F(K)
=F(K)+1
  290   NEXT:NEXT:W=-W:G$=LEFT$(G$,17)
  300 Z$=" where marks are "+G$
  310 IF W=1 THEN X=0
  320 IF (S/9)=INT(S/9) THEN 380
  330 INC=9*INT(S/9)+9-S
  340 D(9)=D(9)+INC
  350 G$=LEFT$(G$,16)+STR$(D(9))
  360 S=S+INC
  370 Q$="Mean mark scored where marks a
re "+G$
  380 H$="mean = total marks scored / nu
mber  of scores":A=INT(S/9)
  390 L$=STR$(A)+" as sum of ("+G$+")/9 
= "+STR$(A)
  400 IF W=1 THEN M$="":GOTO510
  410 X=0:P$=STR$(RND(4)):A=F(VAL(P$))
  420 Q$="Length of histogram rectangle 
of mark "+P$+Z$
  430 H$="length is number of scores wit
h mark "+P$
  440 L$=STR$(A):M$="as there are "+STR$
(A)+" scores of mark "+P$:IF A=1 THEN M$
="as there is 1 score of mark "+P$
  450 N$(0)="":N$(1)=""
  460 FOR I=9 TO 1 STEP -1:FOR K=1 TO 4
  470   IF F(K)>=I THEN N$(INT(I/5))=N$(
INT(I/5))+" "+STRING$(9,CHR$(128))
  480   IF F(K)<I THEN N$(INT(I/5))=N$(I
NT(I/5))+"          "
  490 NEXTK:NEXTI
  500 N$(0)=N$(0)+"     1         2     
    3         4"
  510 ENDPROC
  520 DEFPROC_CALC
  530 VP=VPOS:PRINTTAB(0,22)"         Ca
lculator mode              "TAB(0,22)
  540 B$=""
  550 I$=GET$:PRINTI$;:B$=B$+I$:IF I$<> 
"="AND I$<>"?" AND B$<>"AC"THEN550
  560 IFB$="?"ORI$="?"THEN600
  570 IFB$="AC"THENPRINTTAB(0,23)S$;TAB(
0,22):GOTO540
  580 IFLEN(B$)<=1 THEN 540
  590 PRINTEVAL LEFT$(B$,LEN(B$)-1);TAB(
0,22):GOTO540
  600 PRINTTAB(0,22)S$;S$;TAB(0,VP-1):PR
OC_KEYIN:PRINT
  610 ENDPROC
  612 DEFPROC_KEYIN
  620 IX=1:VP=VPOS:HP=POS
  630 IP$(IX)=INKEY$(10):IF IP$(IX)="" T
HEN COLOUR0:COLOUR129:PRINTTAB(0,1);INT(
TIME/100);"    ";HC$;MAX;HK$;C:COLOUR1:C
OLOUR128:GOTO630
  640 PRINTTAB(IX+HP,VP);IP$(IX);:IX=IX+
1:IP$(IX)=GET$:IF IP$(IX) <> CHR$(13) TH
EN 640
  650 I$="":FORI=1 TO IX-1:I$=I$+IP$(I):
NEXTI
  660 ENDPROC
  670 DEFPROC_SCORE
  680 CLS
  690 PRINT:PRINT
  700 PRINT:PRINT"Number of problems com
pleted = ";P
  710 PRINT:PRINT"Number correct        
       = ";C
  720 TM=INT(TIME/100):PRINT'"Time taken
 in seconds        = ";TM
  730 IF C<>0 THEN PRINT'"Time per probl
em             = ";INT(TM/C)
  740 IF C>MAX THEN MAX=C
  750 TIME=0:P=0:C=0
  760 ENDPROC
 9999 REM