i don not understand why the compiler does not want to accept the loop
sorry i dont know how to quote the code properly (new to the forum)
the problem is that it does dot accept the for loop when im trying to write the rolls till the dice shows 6 of different trys in an array .
It would be helpful for you to update your code to use proper indentation. Code is surprisingly hard to read when it is not properly indented.
Also please include the exact text of the compiler errors you are getting.
You would appear to have used the code tags correctly, but the code isn't formatted correctly. It also isn't correct to make everything static as you have done. It is usually better to use a Random instance than to try arithmetic on Math#random.
The reason you can't get it to compile is that you have declared the same variable twice in lines 8 and 9. You also don't want the cast in line 11. Which program is giving you those error message? Is it Eclipse?
I am forced by my university to use drjava which is using eclipse compiler when i am not wrong.
i did not understood what you ment by "cast" further the error i am receiving is
File: /Users/Sommerfeld/Desktop/programming/RollingDice.java [line: 7]
Error: Syntax error on token(s), misplaced construct(s)
File: /Users/Sommerfeld/Desktop/programming/RollingDice.java [line: 11]
Error: Syntax error on token "}", delete this token
and what else can i write instead of static and why is it better to use something different,
sorry im have not programmed for quite some years but i really appreciate the help
You should write a class with the data as a field and create an instance of that class. I think you need the array as a field and it might be worth having a Random object as a field, too.
Thank you for correcting the indentation but I suspect some of the line numbers have changed. I presume you corrected the compiler errors?
the ones that i posted were regarding the updated code
Your program has logic errors, too, but we'll leave that to you to figure out once you get it running.
Assuming you haven't fixed them with Campbell's and Junilu's help, of course.
Also trinals will not be auto spell-checked as trials, it's up to you to watch out for these kind of differences. These are usually reported by the compiler as "undefined token" or something like that.
sorry for the greenhorn mistakes.
how do i declare this post as solved
Thank you for the remark
I am going to add the final code once again and close the thread thank you to all who helped me
(EDIT: Ignore this comment - I misinterpreted the code)
can be and can be
Junilu Lacar wrote:So, your throwsTillSix() method will always return the number 6. Is that really what you want it to do? What's the point of all the code in there then?
My mistake -- I guess it returns the number of tries to get a roll of 6. I read the code wrong.