Ocean7647
Badges: 5
Rep:
?
#1
Report Thread starter 3 weeks ago
#1
Help can someone send me their code for task 2 im stuck and have no clue how to do this
0
reply
jmh9374
Badges: 2
Rep:
?
#2
Report 3 weeks ago
#2
I am a CS student at A-Level, im not doing the NEA but what is the issue and ill see if can help.
0
reply
Ocean7647
Badges: 5
Rep:
?
#3
Report Thread starter 3 weeks ago
#3
Name:  image.jpg
Views: 22
Size:  129.8 KB

(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.
0
reply
jmh9374
Badges: 2
Rep:
?
#4
Report 3 weeks ago
#4
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.
0
reply
winterscoming
Badges: 19
Rep:
?
#5
Report 3 weeks ago
#5
(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/sho...4&postcount=13
(the answer is the same in any language..)
Last edited by winterscoming; 3 weeks ago
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

University open days

  • Bournemouth University
    Midwifery Open Day at Portsmouth Campus Undergraduate
    Wed, 16 Oct '19
  • Teesside University
    All faculties open Undergraduate
    Wed, 16 Oct '19
  • University of the Arts London
    London College of Fashion – Cordwainers Footwear and Bags & Accessories Undergraduate
    Wed, 16 Oct '19

How has the start of this academic year been for you?

Loving it - gonna be a great year (131)
17.99%
It's just nice to be back! (197)
27.06%
Not great so far... (263)
36.13%
I want to drop out! (137)
18.82%

Watched Threads

View All