?

AP® Computer Science Principles

Free Version

Upgrade subject to access all content

Difficult

Two Dice

APCSP-KXNWY4

You want to simulate rolling two six-sided dice. You are interested in how often you see a sum of 7 on the two dice.

Which of the following would simulate counting the number of times one would see a sum of 7 on two dice rolls when rolling the dice 25 times?

Select TWO answers.

A
q ← 0
REPEAT 25 TIMES {
    a ← RANDOM(1,6) + RANDOM(1,6)
    IF (a = 7) {
        q ← q +1
    }
}
DISPLAY (q)
B
q ← 0
REPEAT 25 TIMES {
    a ← RANDOM(1,6)  
    b ←  RANDOM(1,6)
    IF (a = 7) {
        q ← q + 1
    }
}
DISPLAY (q)
C
q ← 0
REPEAT 25 TIMES {
    a ← RANDOM(2,12)
    IF (a = 7) {
        q ← q +1
    }
}
DISPLAY (q)
D
q ← 0
REPEAT 25 TIMES {
    a ← 0 
    REPEAT 2 TIMES {
        a ← a + RANDOM(1,6)   
    }
    IF (a = 7) {
        q ←  q + 1
    }
}
DISPLAY (q)