New to Java on this end. I'm trying to run a program that rolls two dice and when the total roll between the two die is either 7 or 11 the program will exit. For some reason my while statement is executing over and over again, and I can't figure out why. Any help would be really appreciated. Code is below.
Again, very new to this. Not so much focused on a more efficient way to do this at the very moment, but rather the semantic details of why this is not functioning.
// import required packages for the program
// import all classes to be on the safe side
// will be using input/ouput and math, so those imports are needed
import java.io.*;
import java.math.*;
import java.text.*;
// Declare a class, class name Dice chosen
public class Dice
{
// need to use throws IOException because we are dealing with input and output, simple main method will not suffice
public static void main(String[] args) throws IOException
{
// declare variables for the two dice, randomize each
// die can each be rolled for # between 1-6
double dice1 = Math.round(Math.random() * 6) + 1;
double dice2 = Math.round(Math.random() * 6) + 1;
// declare variable for combined roll
double totalRoll = dice1 + dice2;
//create loop to determine if totalRoll is a 7 or 11, if not continue rolling
while ((totalRoll != 7.0) || (totalRoll != 11.0))
{
dice1 = Math.round(Math.random() * 6) + 1;
dice2 = Math.round(Math.random() * 6) + 1;
totalRoll = dice1 + dice2;
System.out.println("The roll on die 1 is: " + dice1);
System.out.println("The roll on die 2 is: " + dice2);
System.out.println("The total of the two rolls is: " + totalRoll + "\n");
if ((totalRoll == 7.0) || (totalRoll == 11.0))
{
System.out.println("You win!");
}
}
/*
// declare in as a BufferedReader; used to gain input from the user
BufferedReader in;
in = new BufferedReader(new InputStreamReader(System.in));
//Simulate tossing of two dice
*/
}
}