+ 1
Why does this not run? I had it running until I tried to make it grammatically correct.
8 ответов
+ 3
Colter that's what this community is for! It's okay to make small mistakes, and don't hesitate to ask again as long as you have tried it and failed. Glad I could help!
+ 2
Colter that is not an error, it's a warning. I just read you code, you have many errors there.
1. After the for loop, you forgot to use the brackets {}
2. Inside the if statement, you're creating a new variable, therefore the condition will always be true
3. Also, inside the same if statement, using:
if (roll == 8 || 11 || 18) will always be true, because even if roll is different than 8, 11 and 18 are considered as true (any value different than 0 is true)
4. To check if a variable is equal to something, you use ==, and not just =. = is used for assinging a value, and == to check if it's equal to a value.
5. When you recalled the function dieRoll(), you're actually generating a new value, so even if the variable roll is equal to 8, 11 or 18, the output of the function will be completly different.
Here is a fix:
1. Just add the brackets
2-3. Don't create a new variable, but check the condition with: if ( roll == 8 || roll == 11 || roll == 18 )
4. use ==
5. Make new variable:
int roll = dieRoll();
+ 2
Here is a small fix to your code:
https://code.sololearn.com/c17meXCSN9Ae/?ref=app
+ 1
What did you understand from the error message ?
+ 1
Colter, dieRoll is an integer, you cannot name a function and an integer with the same name, it must be different.
0
That I couldn't use the function in the output, but that's how it ran when I only had one.
0
Well I fixed half of it now. Thank you. Now I get an output and an error.
0
Wow. Thank you. I was close. I'm new to coding and still figuring it all out. I really appreciate it.