Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+2 votes

If the user picks more than three rounds to run in the program, and if the user enters paper and the computer selects rock it does not award that point for the user. But this error only occurs after the third round.

asked in CSC201 Spring 2021 by (1 point)

good question, I went through this error too!

2 Answers

+3 votes

I suppose that you should make an accumulator variable to count any points for human and computer player.

Creating a new variable (sum) starting at ZERO.
If human wins the computer over in the given round,
assigning one award point for human: sum = sum +1

Make sure the code above is inside the loop and inside the if statements.
Similarly, you do plus one point for your another accumulator variable for computer player if it wins.

Hope this helps!

answered by (1 point)
+3 votes

First, make sure to uncomment the random. seed(1,2,3,4) on line 6, so the results will match the same as the Moodle.

Then what I did was, I set the variable human = 0 and computer = 0 before the loop so it can accumulate,

for each of the if functions, where the computer wins, do computer = computer + 1 and human = human + 1 where human wins,

hope that helps

answered by (1 point)