//************************************************* // Program Name: rollingdice.java * // Author: Pat Moss * // Date: Oct 10, 2005 Rev: 01 * // * // Demonstrate a main driver for pairofdice.class * //************************************************* import java.util.Scanner; public class rollingdice { public static void main (String[] args) { double inputbet = 0.0; // the user's current bet amount int bothValues = 0; // the dice current composite value int faceValue1 = 0; // the die1 current face value int faceValue2 = 0; // the die2 current face value int bothSum = 0; // the sum of the two dice values // pairofdice pairofdice1; pairofdice pairofdice1 = new pairofdice(); Scanner scan = new Scanner(System.in); System.out.println ("rollingdice.java by pat moss"); System.out.println (""); System.out.print ("Enter a positive double value for your bet (0 to quit): "); inputbet = scan.nextDouble(); while (inputbet != 0) // Use the sentinel value of 0 to terminate the loop { if(inputbet < 0) { System.out.println ("Invalid input value. Please reenter a positive double value."); } else { for (int i = 1; i < 6; i++) { bothValues = pairofdice1.throwdice(); faceValue1 = bothValues / 10; faceValue2 = bothValues % 10; bothSum = faceValue1 + faceValue2; System.out.println (""); System.out.println ("Throw #" + i + ":"); System.out.print ("Dice values are: "); System.out.print (faceValue1 + " " + faceValue2); System.out.println (" and the Sum is: " + bothSum); } } System.out.println (""); System.out.print ("Enter a positive double value for your bet (0 to quit): "); inputbet = scan.nextDouble(); } System.out.println ("All Done..."); } }