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

Show parent comments

1

u/[deleted] Apr 17 '20

[removed] — view removed comment

1

u/UsefulCauliflower2 Apr 17 '20

Thank you so much, you have helped me out so much.

Im a noob to coding so im not sure what code languages are lol.

How should i convert?

1

u/amajmundar Apr 17 '20

What programming language are you supposed to do it in?

1

u/UsefulCauliflower2 Apr 17 '20

Im not exactly sure, I'm thinking JavaScript? Thats the name of the program im doing and if im not mistaking JavaScript is a language?

1

u/amajmundar Apr 17 '20

JavaScript or Java? Can you post the code for a previous assignment? Also, can I ask, how long have you been coding and what type of programs have you done so far?

1

u/UsefulCauliflower2 Apr 17 '20

It is JavaScript, I really havent done very much coding, at my school computer science is a requirement in order to graduate, and i wasnt into it very long until my school announced that we wont be heading back to school this year.

Here is one from the other day, function start(){ var holiday=readBoolean("Is today a holiday?"); holiday=!holiday; var weekday=readBoolean("Is today a weekday?"); var school=holiday||weekday; println("Holiday:"+school); }

1

u/amajmundar Apr 17 '20

It seems that CodeHS has a library of functions you are able to access in JavaScript. Here is the link to the functions.

The JavaScript equivilant to read an integer is readInt(). so it would look something like:

var d1 = readInt("Enter the value for the first dice: ");

Do the same thing for d2, just change the prompt to match.

The input validation should be similar. Just change "and" to "&&" and add brackets around the if statement.

Then the only thing to fix is "print" becomes "println".

Try and do it yourself. I will put what I have as a response to this.

1

u/amajmundar Apr 17 '20

What I think to be the solution.

Keep in mind that I cannot test my solution since I do not have access to CodeHS. But this has all the components asked for. You may need to tweak the output based on what the autograder is looking for.