I want the program to keep incrementing the innings for each iteration of the loop. When I run the program it's doing that, however it's showing me incorrect values.
For example: You rolled...4 Your total for this innings so far is 6
The second line should be showing, "... so far is 4"
This is the code that I have at the moment:
import java.util.Random;
import javax.swing.*;
public class shortSix {
public static void main(String[] args) {
diceGame();
}//ENDS MAIN
public static void diceGame()
{
final int[] innings = new int[1];
innings[0] = 0;
Random dice = new Random();
int diceRoll = dice.nextInt(6) + 1;
while (diceRoll != 5)
{
System.out.println("You rolled..." + diceRoll);
diceRoll = dice.nextInt(6) + 1;
innings[0] =+ diceRoll;
System.out.println("Your total for this innings so far is " + innings[0]);
String userDeclare = JOptionPane.showInputDialog(null, "Do you wish to declare?");
if (userDeclare.equals("yes"))
{
System.exit(0);
}
}
}//ENDS diceGame
}//ENDS class shortSix
inningsdefinedfinal?=+ininnings[0] =+ diceRoll?