!Angela Choi

!12/01/06

!9th Grade

!Montgomery Blair 8009

!Intermediate 5

!Contest 1

 

FOR s=1 to 5

    LET n=1

    LET d=1

    GET KEY x

    LET a=val(chr$(x))

    PRINT a;

    GET KEY x

    PRINT chr$(x);

    IF a=1 then

       INPUT prompt "":red, blue, first$

       IF first$="r" or first$="B" then

          LET n=blue

          LET d=red+blue

       ELSE IF first$="b" or first$="R" then

          LET n=red

          LET d=red+blue

       END IF

    ELSE

       INPUT prompt "":red, blue, rep$, first$, next$

       IF ucase$(rep$)="Y" then

          LET d=(red+blue)^2

          IF first$="R" or first$="b" then

             LET n=red

          ELSE

             LET n=blue

          END IF

          IF next$="R" or next$="b" then

             LET n=n*red

          ELSE

             LET n=n*blue

          END IF

       ELSE

          LET d=(red+blue)*(red+blue-1)

          IF first$="R" or first$="b" then

             LET n=red

             LET red=red-1

          ELSE

             LET n=blue

             LET blue=blue-1

          END IF

          IF next$="R" or next$="b" then

             LET n=n*red

          ELSE

             LET n=n*blue

          END IF

       END IF

    END IF

    PRINT n;"/";d

NEXT s

END