The Student Room Group

Computer science NEA 2019 task 2

Help can someone send me their code for task 2 im stuck and have no clue how to do this
Reply 1
I am a CS student at A-Level, im not doing the NEA but what is the issue and ill see if can help.
Reply 2
image.jpg

Original post by jmh9374
I am a CS student at A-Level, im not doing the NEA but what is the issue and ill see if can help.
Reply 3
Okay the way I would personally do this is have a while loop and have a variable that increases by one every time it loops. Then when the loop hits 5 then it breaks out of the while loop and then you calculate the scores. To deal with the doubles you can just have a if statement stating if the two dices have the same number roll another one. Also to handle the die I would have THREE dice variables called something like; intDieOne, intDieTwo, intDieThree so that you can easily add them to their scores in the loop you also want to make sure at the start of each loop these are reset or you might get an error. Once calculated the scores and if they are the same (Just use a if statement to test this) roll another dice for each. The odd and even is easy as if you divide by 2 if it is a whole number it is even (a int) or if it has decimal and need to be converted to a float its odd. To roll dice it depends on the language you are using but almost all new-ish languages have a random function with the ability to change the min and max numbers rolled.

If you have any questions feel free to ask.
Original post by Ocean7647
Help can someone send me their code for task 2 im stuck and have no clue how to do this


I answered a pretty similar thread over here: https://www.thestudentroom.co.uk/showpost.php?p=85202944&postcount=13
(the answer is the same in any language..)
(edited 4 years ago)

Quick Reply

Latest