Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This original program lets the user enter in a bank amount, a bet,and a guess. I

ID: 3614586 • Letter: T

Question

This original program lets the user enter in a bank amount, a bet,and a guess. If the user gets the number right, their bank willincrease. If wrong, their bank will decrease. Depending on thenumber of games, the user can keep on going if money is stillavailable.
I need to modify the orginal program by having adriver class and a die class. The new program must do thatsame things that the orginal program does, but it must contain 2dice and the user must correctly guess the sum of die 1+2 toincrement the bank. Each die shold be instantiated for atotal of 2 die ojects in the driver class. Useencapsulation as well as java methods. I tried to do thedie class, but I need your help to finish it.


ORINGAL PROGRAM/ drive class import java.util.Scanner; import java.util.Random;
public class RollTheDie { public static void main (String[] args) { final int MIN_BET = 10, MAX_BET = 100; int userBank, userBet, userGame, userGuess, dieNum, count =0; Random generator = new Random(); Scanner scan = new Scanner (System.in); System.out.println ("Please enter the amount add to thebank:"); userBank = scan.nextInt(); System.out.println ("How many games would you like toplay?"); userGame = scan.nextInt(); while (count < userGame) //Loop for how many games userwants to play { System.out.println ("Enter your bet:"); userBet = scan.nextInt();
while(userBet < MIN_BET || userBet > MAX_BET || userBet> userBank) { System.out.println ("Incorrect bet amount"); System.out.println ("Enter a bet between $10 and $" + userBank+ " and less than or equal to your bank of $" + userBank); userBet = scan.nextInt(); } dieNum = generator.nextInt(6) + 1; //Generates dice randomnumbers 1-6 System.out.println ("Enter your guess:"); userGuess = scan.nextInt(); if (userGuess != dieNum) //Subtracts bet from bank ifwrong { userBank = userBank - userBet; System.out.println ("Your Bank = $" + (userBank)); System.out.println ("The correct guess was: " + dieNum); } else //Adds bet to bank if correct { userBank = userBank + userBet; System.out.println ("Your Bank = " + (userBank)); System.out.println ("Correct guess!"); } if (userBank < 10) //Kicks user out if Bank is <10 { System.out.println ("No Cash To Play, Bye"); System.exit(0); //Terminates program if bank is zero ornegative } count++; } //Ends counter while loop System.out.println ("Thanks for playing David's dicegame!"); } //End of main }//End of class
DIE CLASS public class Die { private final int MAX = 6; private int faceValue; // Constructor public Die() { faceValue = 1; } // Computes a new fac calue for this die and returns theresult public int roll() { faceValue = (int)(Math.random() * MAX) +1; return faceValue; } // Face calue mutator public void setFaceValue (int value) { if (value > 0 && value <= MAX) faceValue = value; } // Face value accessor public int getFaceValue() { return faceValue; } // Returns a string representation of this die public String toString() { String result = Integer.toString(faceValue); return result; } }
I need to modify the orginal program by having adriver class and a die class. The new program must do thatsame things that the orginal program does, but it must contain 2dice and the user must correctly guess the sum of die 1+2 toincrement the bank. Each die shold be instantiated for atotal of 2 die ojects in the driver class. Useencapsulation as well as java methods. I tried to do thedie class, but I need your help to finish it.


ORINGAL PROGRAM/ drive class import java.util.Scanner; import java.util.Random;
public class RollTheDie { public static void main (String[] args) { final int MIN_BET = 10, MAX_BET = 100; int userBank, userBet, userGame, userGuess, dieNum, count =0; Random generator = new Random(); Scanner scan = new Scanner (System.in); System.out.println ("Please enter the amount add to thebank:"); userBank = scan.nextInt(); System.out.println ("How many games would you like toplay?"); userGame = scan.nextInt(); while (count < userGame) //Loop for how many games userwants to play { System.out.println ("Enter your bet:"); userBet = scan.nextInt();
while(userBet < MIN_BET || userBet > MAX_BET || userBet> userBank) { System.out.println ("Incorrect bet amount"); System.out.println ("Enter a bet between $10 and $" + userBank+ " and less than or equal to your bank of $" + userBank); userBet = scan.nextInt(); } dieNum = generator.nextInt(6) + 1; //Generates dice randomnumbers 1-6 System.out.println ("Enter your guess:"); userGuess = scan.nextInt(); if (userGuess != dieNum) //Subtracts bet from bank ifwrong { userBank = userBank - userBet; System.out.println ("Your Bank = $" + (userBank)); System.out.println ("The correct guess was: " + dieNum); } else //Adds bet to bank if correct { userBank = userBank + userBet; System.out.println ("Your Bank = " + (userBank)); System.out.println ("Correct guess!"); } if (userBank < 10) //Kicks user out if Bank is <10 { System.out.println ("No Cash To Play, Bye"); System.exit(0); //Terminates program if bank is zero ornegative } count++; } //Ends counter while loop System.out.println ("Thanks for playing David's dicegame!"); } //End of main }//End of class
DIE CLASS public class Die { private final int MAX = 6; private int faceValue; // Constructor public Die() { faceValue = 1; } // Computes a new fac calue for this die and returns theresult public int roll() { faceValue = (int)(Math.random() * MAX) +1; return faceValue; } // Face calue mutator public void setFaceValue (int value) { if (value > 0 && value <= MAX) faceValue = value; } // Face value accessor public int getFaceValue() { return faceValue; } // Returns a string representation of this die public String toString() { String result = Integer.toString(faceValue); return result; } }

ORINGAL PROGRAM/ drive class import java.util.Scanner; import java.util.Random;
public class RollTheDie { public static void main (String[] args) { final int MIN_BET = 10, MAX_BET = 100; int userBank, userBet, userGame, userGuess, dieNum, count =0; Random generator = new Random(); Scanner scan = new Scanner (System.in); System.out.println ("Please enter the amount add to thebank:"); userBank = scan.nextInt(); System.out.println ("How many games would you like toplay?"); userGame = scan.nextInt(); while (count < userGame) //Loop for how many games userwants to play { System.out.println ("Enter your bet:"); userBet = scan.nextInt();
while(userBet < MIN_BET || userBet > MAX_BET || userBet> userBank) { System.out.println ("Incorrect bet amount"); System.out.println ("Enter a bet between $10 and $" + userBank+ " and less than or equal to your bank of $" + userBank); userBet = scan.nextInt(); } dieNum = generator.nextInt(6) + 1; //Generates dice randomnumbers 1-6 System.out.println ("Enter your guess:"); userGuess = scan.nextInt(); if (userGuess != dieNum) //Subtracts bet from bank ifwrong { userBank = userBank - userBet; System.out.println ("Your Bank = $" + (userBank)); System.out.println ("The correct guess was: " + dieNum); } else //Adds bet to bank if correct { userBank = userBank + userBet; System.out.println ("Your Bank = " + (userBank)); System.out.println ("Correct guess!"); } if (userBank < 10) //Kicks user out if Bank is <10 { System.out.println ("No Cash To Play, Bye"); System.exit(0); //Terminates program if bank is zero ornegative } count++; } //Ends counter while loop System.out.println ("Thanks for playing David's dicegame!"); } //End of main }//End of class
DIE CLASS public class Die { private final int MAX = 6; private int faceValue; // Constructor public Die() { faceValue = 1; } // Computes a new fac calue for this die and returns theresult public int roll() { faceValue = (int)(Math.random() * MAX) +1; return faceValue; } // Face calue mutator public void setFaceValue (int value) { if (value > 0 && value <= MAX) faceValue = value; } // Face value accessor public int getFaceValue() { return faceValue; } // Returns a string representation of this die public String toString() { String result = Integer.toString(faceValue); return result; } } import java.util.Scanner; import java.util.Random;
public class RollTheDie { public static void main (String[] args) { final int MIN_BET = 10, MAX_BET = 100; int userBank, userBet, userGame, userGuess, dieNum, count =0; Random generator = new Random(); Scanner scan = new Scanner (System.in); System.out.println ("Please enter the amount add to thebank:"); userBank = scan.nextInt(); System.out.println ("How many games would you like toplay?"); userGame = scan.nextInt(); while (count < userGame) //Loop for how many games userwants to play { System.out.println ("Enter your bet:"); userBet = scan.nextInt();
while(userBet < MIN_BET || userBet > MAX_BET || userBet> userBank) { System.out.println ("Incorrect bet amount"); System.out.println ("Enter a bet between $10 and $" + userBank+ " and less than or equal to your bank of $" + userBank); userBet = scan.nextInt(); } dieNum = generator.nextInt(6) + 1; //Generates dice randomnumbers 1-6 System.out.println ("Enter your guess:"); userGuess = scan.nextInt(); if (userGuess != dieNum) //Subtracts bet from bank ifwrong { userBank = userBank - userBet; System.out.println ("Your Bank = $" + (userBank)); System.out.println ("The correct guess was: " + dieNum); } else //Adds bet to bank if correct { userBank = userBank + userBet; System.out.println ("Your Bank = " + (userBank)); System.out.println ("Correct guess!"); } if (userBank < 10) //Kicks user out if Bank is <10 { System.out.println ("No Cash To Play, Bye"); System.exit(0); //Terminates program if bank is zero ornegative } count++; } //Ends counter while loop System.out.println ("Thanks for playing David's dicegame!"); } //End of main }//End of class
DIE CLASS public class Die { private final int MAX = 6; private int faceValue; // Constructor public Die() { faceValue = 1; } // Computes a new fac calue for this die and returns theresult public int roll() { faceValue = (int)(Math.random() * MAX) +1; return faceValue; } // Face calue mutator public void setFaceValue (int value) { if (value > 0 && value <= MAX) faceValue = value; } // Face value accessor public int getFaceValue() { return faceValue; } // Returns a string representation of this die public String toString() { String result = Integer.toString(faceValue); return result; } } public class Die { private final int MAX = 6; private int faceValue; // Constructor public Die() { faceValue = 1; } // Computes a new fac calue for this die and returns theresult public int roll() { faceValue = (int)(Math.random() * MAX) +1; return faceValue; } // Face calue mutator public void setFaceValue (int value) { if (value > 0 && value <= MAX) faceValue = value; } // Face value accessor public int getFaceValue() { return faceValue; } // Returns a string representation of this die public String toString() { String result = Integer.toString(faceValue); return result; } }

Explanation / Answer

x.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote