writing an application but the numbers wont add up, help please
<p>I am restating my question as it was previously unclear.</p>

<p>I am currently writing a dice rolling application which randomly rolls dice, displays them, and prompts the user to do it again.  The program is composed of 4 classes, the Die class which creates Die objects, the PairOfDice Class which knows about rolling 2 dice, and a validator class which validated user input to avoid exceptions.  I have written all of the code and am struggling with a puzzling problem.</p>

<p>The program is supposed recognize certain values of a dice roll. For example, if the user rolls 1 and 1 it should say snake eyes!, when rolling double 6's it says box cars! etc.  To accomplish this I have added code that adds the values of both die rolls and determines whether or not they fall into the category.  </p>

<p>So finally my question is as follows:  When I run the application, it works fine aside from the fact that the numbers it displays and the sum it gets from both dice do not match up, essentially i will see a roll of (for example) 2 and 4 and see an actual total of 10 ( I added a control statement to display the the actual total)</p>

<p>so basically the numbers do not match and im not sure why... </p>

<p>any advice is appreciated!</p>

<pre><code>public class DiceRollerApp {

public static void main(String[] args) {
    System.out.println("Welcome to the Paradise Roller Application!");
    System.out.println("GOOD LUCK!");

    System.out.println();

    Scanner sc = new Scanner(System.in);

    int rollCounter;
    rollCounter = 0;

    PairOfDice dice;
    dice = new PairOfDice();

    String choice = Validator.getString(sc, "Roll the Dice? (y/n): ");

    while (choice.equalsIgnoreCase("y")) {

        DiceRoller.rollDice();
        rollCounter++;  //the counter is incremented

        System.out.println("ROLL " + rollCounter + ":");
        System.out.println(dice.getValue1());
        System.out.println(dice.getValue2());
        System.out.println();

        dice.roll();


        choice = Validator.getString(sc, "Roll again? (y/n): ");
        System.out.println();
    }   System.out.println();
   }
   }
   class Die    //this is a problem, how do i use this class for the PairOfDice class                     
  PairOfDice class
  {
  private int sides;

  private int value;

  public Die() {
    this.sides = 6;
  }           // default to six-sided die

  public Die(int sides) {
    this.sides = sides;
  }  // variable number of sides

  public void roll() {
    value = (int)(Math.random() * (sides-1)) + 1;
  }     // randomly picks a face value

  public int getValue() {
    return value;
  }  

  }

  class PairOfDice   //i think this might be the culprit
 {  

  private int die1;   // Instance variable for number showing on the first die.  
  private int die2;   // Instance variable for number showing on the second die.  
  private int sum;    // Instance variable to hold sum of two dice  

  public PairOfDice() // default to six-sided dice  
 {  
    roll();  // Calls the roll() method to roll the dice.  
 }  


 public void roll()   // is this right??
 {  
    die1 = (int)(Math.random()*6) + 1;  
    die2 = (int)(Math.random()*6) + 1;    
 }  

 public int getValue1() // Return the number showing on the first die.  
 {  
    return die1;  
 }  

 public int getValue2() // Return the number showing on the second die.  
 {  
    return die2;  
 }  

 public int getSum() // Return the total showing on the two dice.  
 {  
    sum = die1 + die2;  
    return sum;  
 }  }

class Validator {

public static String getString(Scanner sc, String prompt) {
    System.out.print(prompt);
    String s = sc.next();  // read user entry
    sc.nextLine();  // discard any other data entered on the line
    return s;
}

public static int getInt(Scanner sc, String prompt) {
    int i = 0;
    boolean isValid = false;
    while (isValid == false) {
        System.out.print(prompt);
        if (sc.hasNextInt()) {
            i = sc.nextInt();
            isValid = true;
        } else {
            System.out.println("Error! Invalid integer value. Try again.");
        }
        sc.nextLine();  // discard any other data entered on the line
    }
    return i;
}

public static int getInt(Scanner sc, String prompt,
        int min, int max) {
    int i = 0;
    boolean isValid = false;
    while (isValid == false) {
        i = getInt(sc, prompt);
        if (i &lt;= min) {
            System.out.println(
                    "Error! Number must be greater than " + min + ".");
        } else if (i &gt;= max) {
            System.out.println(
                    "Error! Number must be less than " + max + ".");
        } else {
            isValid = true;
        }
    }
    return i;
}

public static double getDouble(Scanner sc, String prompt) {
    double d = 0;
    boolean isValid = false;
    while (isValid == false) {
        System.out.print(prompt);
        if (sc.hasNextDouble()) {
            d = sc.nextDouble();
            isValid = true;
        } else {
            System.out.println("Error! Invalid decimal value. Try again.");
        }
        sc.nextLine();  // discard any other data entered on the line
    }
    return d;
}

public static double getDouble(Scanner sc, String prompt,
        double min, double max) {
    double d = 0;
    boolean isValid = false;
    while (isValid == false) {
        d = getDouble(sc, prompt);
        if (d &lt;= min) {
            System.out.println(
                    "Error! Number must be greater than " + min + ".");
        } else if (d &gt;= max) {
            System.out.println(
                    "Error! Number must be less than " + max + ".");
        } else {
            isValid = true;
        }
    }
    return d;
  }
}

class DiceRoller {  // this class is responsible for rolling the dice

public static void rollDice() {

    PairOfDice dice;
    dice = new PairOfDice();

    dice.roll();
        System.out.println(dice.getSum()); //control statement to see what the actual sum       is

    if (dice.getSum() == 7) {
        System.out.println("Craps!" + "\n");
    } else if (dice.getSum() == 2) {
        System.out.println("Snake eyes!" + "\n");
    } else if (dice.getSum() == 12) {
        System.out.println("Box cars!" + "\n");
    }
   }
   }
</code></pre>
