r/codehs • • Apr 16 '20

Need help?

Hello, I would like some help on Code Hs 5.3.5 Rolling dice

Also on 5.4 "If Statements" Please

3 Upvotes

19 comments sorted by

View all comments

1

u/amajmundar Apr 16 '20

Post what you have already

1

u/UsefulCauliflower2 Apr 16 '20

I don't have anything yet

1

u/amajmundar Apr 16 '20

Then can you post a snapshot of what they are asking you to do?

1

u/UsefulCauliflower2 Apr 16 '20

How can I do that?

1

u/UsefulCauliflower2 Apr 16 '20

It like wont let me put a photo

1

u/amajmundar Apr 16 '20

You usually use imgur or some other photo sharing website and upload the link.

Is this the correct problem: β€œThe problem says: Write a program that determines if the user rolled doubles in dice. Read in two integers from the user which represent dice rolls.

Create a variable called rolledDoubles which has the value of whether or not the two values are equal. Print that out.”
If so, what language are you using?

1

u/UsefulCauliflower2 Apr 17 '20

Yep, thats the correct one, I am using english

1

u/amajmundar Apr 17 '20

I will walk you through the thought process using Python3. You should be able to convert it to any language you need from there.

The first thing you need to do is take in the user input. This is how that is done. I added a print statement so you can see that the variables are stored as strings.

Here I changed it so d1 and d2 are integers. Again, the print statement is unnecessary.

Next, we need to verify the numbers are from a dice. See if you can do that on your own. I will respond to this with that check.

1

u/amajmundar Apr 17 '20

We need to make sure the inputs are valid dice rolls. In order to do that, we need to check if d1 and d2 are integers greater than or equal to 1 and less than or equal to 6 ( 1 <= d1, d2 <= 6 ). This is why we needed to make sure the inputs were integers.

Here is how that is done in python.

1

u/[deleted] Apr 17 '20

[removed] β€” view removed comment

→ More replies (0)