java - Problems assigning variable to the return of a function -


I'm searching online for a solution to this problem, but one can not get it with Java I am beginning to begin, so I do not understand many errors and that is why I was not able to correct myself.

However, I am trying to allocate a value for the variable and then add the int value from the variable to the second, I am getting errors when compiling: "This is not a statement" and a There is an error that I am missing a semicolon, which I suspect is that if I fix the statement it will be cleaned.

Here's an error, just you need it:

  hw8_ex2_jm2rv.java:61: Error: ';' Expected Sum sumOfGames + = value; ^ Hw8_ex2_jm2rv.java:61: Error: not a statement int sumOfGames + = value; ^ 2 Errors  

This is my code:

  Public Fixed In One Game () {int trueValue = 1; Int falseValue = 0; Intel Total = sumTwoDice (); If ((total == 7) || (total == 11)) {//System.out.println(trueValue + "" + total); Return true (trueValue); } And if ((total == 2) || (total == 3) || (total == 12)) {//System.out.println(falseValue + "" + total); Return false (falseValue); } And {int total2 = 0; While ((total 2! = 7) || (total 2! = Total)) {total2 = sumTwoDice (); If (total 2 == total) {//System.out.println (trueValue + "" + + "+ +" total 2); Return true (trueValue); } And if (total 2 == 7) {//System.out.println(falseValue + "" + total + "" + total2); Return false (falseValue); }}}}  

You are probably thinking about sumTwoDice method, all this returns a number between 2 and 12 and I already know that it is working is. If you want to see it I can also post it, just ask.

A game function simply degrades the game of craps and returns an integer value to 1 or 0. 1 is going to win and loss of 0.

  // This method imitates n values ​​and returns the average. Public stable double Monte Carloos () {int trueValue = 1; Int falseValue = 0; Int sumOfGames = 0; Int n = 2; (Int i = 0; i & lt; = n; i ++) for {int value = oneGame (); Int sumOfGames + = value; } Double Average = sumOfGames / n; Return (average); }  

I have a small enfluenza at the moment, so that it is easy to compile and be fast to compile.

My main question is what denies this statement and how can I fix it, but still many threads do not cover it on stack overflow, do a < / Strong> Invalid description in general is expected that it will not be able to understand this error to me and other beginners.

Thank you in advance for your help and knowledge!

Announce your own value outside the loop:

  int sumOfGames = 0;  

Inside the loop increments:

  int sumOfGames = 0; (Int i = 0; i & lt; = n; i ++) for {int value = oneGame (); SumOfGames + = value; }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -