IF statement accumulataion not working properly - random numbers
I am having trouble figuring out how to write program code that will add up the number of doubles rolled, as well as the number of 7's rolled;the program already notifies the user which dice are 7's and which are doubles.
I know for the accumulation to work, it has to be an IF statement. I placed my IF statement within my MAIN method, but it does not seem to be working properly. For program running purposes only, I /* */ out the IF statement in case you wanted to copy and paste the program to see how it runs without the IF statement.
I am getting the hang of Java, but it's always tricky and confusing a bit.
public class DiceGame
public static void main(String  args)
Random newnum = new Random();
int roll_1 = 0;
int roll_2 = 0;
System.out.println("Dice #1" + "\t" + "\tDice #2");
roll_1=1 + newnum.nextInt(6);
roll_2=1 + newnum.nextInt(6);
System.out.print("\t" + "\t" + " ");
if(Doublecounter > 1)
System.out.print("Number of doubles include: ");
public static boolean Doubles(int roll_1, int roll_2)
System.out.print(" - Doubles were rolled.");
public static boolean Seven(int roll_1, int roll_2)
if((roll_1 + roll_2)==7)
System.out.print(" - The roll totaled 7.");
int total1 = 0;
Re: IF statement accumulataion not working properly - random numbers
The variable that holds the count MUST be defined and initialized outside of the processing loop.